public static ReceivedPacket WaitOnReceive(SockBase sock) { var receivedPacket = new ReceivedPacket(); for (int i = 0; i < 1000; ++i) { if (sock.Receive(ref receivedPacket)) { return(receivedPacket); } Thread.Sleep(1); } return(receivedPacket); }
public SockMgr(SockBase sockBase, Protocol.IProtocolFactory protocolFactory) { _sockBase = sockBase; _sockBase.SocketReceiveEvent += OnSocketReceive; _sockBase.SocketShutdownBeginEvent += OnSocketShutdownBegin; protocolFactory.SetSockMgr(this); // TODO: review _protocolFactory = protocolFactory; if (sockBase.Role == SocketRole.Client) // listener does not need to send or receive { _protocolStack = protocolFactory.GetProtocolStack(); } Responser responser = new Responser(_protocolStack, this); _responser = responser; }