0
嗯,這是我的第一個UDP測試程序,我想我現在明白了一點吧:) 這裏的任何方法是到目前爲止我的代碼:c#UDP檢查我是否收到整個數據包?
static void Main(string[] args)
{
Socket udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
udpSocket.Bind(new IPEndPoint(IPAddress.Any, 111));
Console.WriteLine("Waiting for connection");
byte[] buffer = new byte[1024*64];
int count = udpSocket.Receive(buffer);
IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, 111);
EndPoint endPoint = (EndPoint)ipEndPoint;
udpSocket.ReceiveFrom(buffer, ref endPoint);
Console.WriteLine("Message recived from, " + endPoint.ToString() + " data length: " + count);
Console.ReadKey();
}
但我如何確保我得到了整個包?
好吧,我不知道我會怎麼做? – Peter 2009-09-20 10:30:35