public bool Receive(ref ReceivedSmartPacket receivedPacket) { bool haveResult = false; var packet = new ReceivedPacket(); while (true) { if (SubSock.Receive(ref packet)) { try { haveResult = OnReceive(packet.Buffer, packet.Offset, packet.Length, packet.EndPoint, ref receivedPacket); } catch (Exception) { haveResult = false; _buffersPool.Put(packet.Buffer); } } else { break; } if (haveResult) { break; } } return(haveResult); }
public bool Receive(ref ReceivedSmartPacket receivedPacket) { bool haveResult = false; var packet = new ReceivedPacket(); while (true) { try { packet.EndPoint = null; if (SubSock.Receive(ref packet)) { try { haveResult = OnReceive(packet.Buffer, packet.Offset, packet.Length, packet.EndPoint, ref receivedPacket); } catch (SocketException) { haveResult = false; _buffersPool.Put(packet.Buffer); if (packet.EndPoint != null && _seqStates.ContainsKey(packet.EndPoint)) { Close(packet.EndPoint, _seqStates[packet.EndPoint]); } } } else { break; } } catch (SocketException) { Close(); } if (haveResult) { break; } } return(haveResult); }