private void OnReceived(object sender, SocketAsyncEventArgs eventArgs) { while (true) { if (UdpHelper.IsHarmfulError(eventArgs.SocketError)) { return; } _receiveHandler(eventArgs.Buffer, eventArgs.BytesTransferred); lock (_socket) { if (_disposed) { return; } else if (_socket.ReceiveAsync(eventArgs)) { break; } } } }
private void OnReceived(object sender, SocketAsyncEventArgs eventArgs) { while (true) { if (UdpHelper.IsHarmfulError(eventArgs.SocketError)) { return; } _receiveHandler(eventArgs.RemoteEndPoint, eventArgs.Buffer, eventArgs.BytesTransferred); lock (_socket) { if (_disposed) { return; } eventArgs.RemoteEndPoint = new IPEndPoint(IPAddress.IPv6Any, _port); if (_socket.ReceiveFromAsync(eventArgs)) { break; } } } }