我想要一个实用程序,它允许我发送/接收tcp和udp消息作为客户端或服务器,汇编数据包,设置响应等...最好在Windows上。如果你看过这样的话,请告诉我。谢谢!
答案 0 :(得分:4)
我使用"Hercules SETUP Utility"。乍一看它看起来太简单了,但它确实是非常有用的功能。
答案 1 :(得分:1)
为什么不用其中一种.NET语言在System.Net中尝试TcpClient和TcpListener?使用这些类为您自己实现客户端/服务器系统非常简单。
答案 2 :(得分:0)
您可以在Windows上使用Docklight Scripting的免费评估版(无时间限制)执行以下操作:
我没有尝试过的另一种免费软件解决方案,但看起来非常好Packet Sender
答案 3 :(得分:-1)
//Server Binding
IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList[0];
serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, 2015);
serverSocket.Bind(ipEndPoint);
//Begin Recceive from any client
IPEndPoint ipeSender = new IPEndPoint(IPAddress.Any, 0);
EndPoint epSender = (EndPoint)ipeSender;
serverSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref epSender, new AsyncCallback(OnNetworkBytesReceived), epSender);
private void OnNetworkBytesReceived(IAsyncResult ar)
{
IPEndPoint ipeSender = new IPEndPoint(IPAddress.Any, 0);
EndPoint epSender = (EndPoint)ipeSender;
int BytesRead = serverSocket.EndReceiveFrom(ar, ref epSender);
//parse your data
ParseNetworkBytes(BytesRead, epSender);
serverSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref epSender, new AsyncCallback(OnNetworkBytesReceived), epSender);
}//OnNetworkBytesReceived()
//for sending to client
Byte[] byteDataTemp = msg.messagePacketByLength(i, Constants.MAXSENDBUFFERSIZE);
serverSocket.BeginSendTo(byteDataTemp, 0, byteDataTemp.Length, SocketFlags.None, epRcvr, new AsyncCallback(OnSend), null);
private void OnSend(IAsyncResult ar)
{
try
{
lock (serverSocket)
{
serverSocket.EndSendTo(ar);
}
}
catch (ObjectDisposedException objexp)
{
}
catch (Exception exp)
{
}
}//OnSend()