Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Sockets BeginRecieve Async Callback not being called
    text
    copied!<p>I'm opening a UDP Socket for receiving udp packets. However sometimes It never gets to the point <code>Do stuff with data</code>. </p> <p>Data is being received, I can see it on Wireshark: </p> <p><img src="https://i.stack.imgur.com/97hYi.png" alt="wireshark capture"></p> <p>but the callback only runs to close the socket when I run the Disconnect code.</p> <pre><code> private void OpenUDPSocket() { this.processDataSockets.Clear(); IPHostEntry host; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { UPDData data = new UPDData(); data.Socket = new Socket(ip.AddressFamily, SocketType.Dgram, ProtocolType.Udp); data.Socket.Bind(new IPEndPoint(ip, 2222)); data.Socket.EnableBroadcast = true; data.Buffer = new byte[512]; data.Socket.BeginReceive(data.Buffer, 0, 512, SocketFlags.None, this.ReceivedData, data); this.processDataSockets.Add(data); } this.socketOpen = true; } private void ReceivedData(IAsyncResult ar) { UPDData data; try { data = (UPDData)ar.AsyncState; data.Socket.EndReceive(ar); } catch (ObjectDisposedException) { // The connection has been closed return; } //... Do stuff with data data.Socket.BeginReceive(data.Buffer, 0, 512, SocketFlags.None, this.ReceivedData, data); } </code></pre> <p>When this happens I'm left stuck, restarting the application doesn't help. I need to reboot my machine for the callback to start working again.</p> <p>I have no idea where to go from here or how to fix this. </p> <p>Any Ideas what's happening?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload