Info:Im working on a VOIP application.
Im using the C# Socket class and initalize it as a UDP socket.
My code for receiving:
if(socket.Poll(-1,SelectMode.SelectRead)){
if(!socket.Connected){
return;
}
Console.WriteLine(" AVAIL:"+socket.Available);
int count = socket.ReceiveFrom (data, ref endpoint);
Console.WriteLine("LENGTH:"+count);
receivedEvent.Reuse (socket, data, count, (IPEndPoint)endpoint);
receivedFunction (receivedEvent);
}
My code for sending:
int cnt = socket.SendTo (data, length, SocketFlags.None, ep);
if (cnt != length) {
//LOG STUFF
}
if (sendEvent != null) {
sendEvent (cnt);
}
ERROR: I get unexpected data from my udp socket, meaning im sending ~100 bytes of data but I only receive 31. Which is just wrong => I thought UDP will always give me all or nothing. Am I wrong ?
So my question is, shouldn't UDP be reliable in sense of packets ? Like I only should get valid or none packets ?
Another problem I seem to have (not sure if it is connected to my current issue?), after ~30 minutes my socket only returns 10 as count of data read from socket.
So my question is, shouldn't UDP be reliable in sense of packets ? Like I only should get valid or none packets ?
no unless you use UDP checksums, do you use raw sockets ?
ERROR: I get unexpected data from my udp socket, meaning im sending ~100 bytes of data but I only receive 31. Which is just wrong => I thought UDP will always give me all or nothing. Am I wrong ?
Did you deactivate the IP fragmentation ? https://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient.dontfragment%28v=vs.110%29.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.