This is my current setup (using UDP):
void OnDataReceived(IAsyncResult result) { IPEndPoint ep = new IPEndPoint(IPAddress.Any, 0); byte[] buffer = socket.EndReceive(result, ref ep); Packet p = new Packet(Encoding.ASCII.GetString(buffer, 0, buffer.Length));
I was wondering what would happen if I immediately call socket.BeginReceive after calling EndReceive, and then process the packet to get a continuous stream of packets as follows:
void OnDataReceived(IAsyncResult result) { IPEndPoint ep = new IPEndPoint(IPAddress.Any, 0); byte[] buffer = socket.EndReceive(result, ref ep); socket.BeginReceive(new AsyncCallback(OnDataReceived), socket); Packet p = new Packet(Encoding.ASCII.GetString(buffer, 0, buffer.Length));
If a packet is received as soon as I call BeginReceive, will this conflict with the current packet processing?
Also, if this does not contradict the switch to TCP, do it disfunctional?
source share