private void localReceiveCallback(IAsyncResult ar) { State state = (State)ar.AsyncState; try { EndPoint remoteEP = (EndPoint)(new IPEndPoint(IPAddress.Any, 0)); int bytesRead = _local.EndReceiveFrom(ar, ref remoteEP); if (_pipe.CreatePipe(state.buffer, bytesRead, _local, remoteEP)) { return; } // do nothing } catch (ObjectDisposedException) { } catch (Exception e) { Logging.LogUsefulException(e); } finally { localStartReceive(); } }
private void localReceiveCallback(IAsyncResult ar) { if (_local == null) { return; } State state = (State)ar.AsyncState; try { EndPoint remoteEP = (EndPoint)(new IPEndPoint(IPAddress.Any, 0)); int bytesRead = _local.EndReceiveFrom(ar, ref remoteEP); Logging.Debug($"recv {bytesRead} bytes from {remoteEP}"); _pipe.CreatePipe(state.buffer, bytesRead, _local, remoteEP); } catch (Exception e) { Logging.LogUsefulException(e); } finally { localStartReceive(); } }