/// <summary> /// Initiate method for asynchronous receive operation of payload data in "payload-unaware" mode. /// </summary> private void ReceivePayloadUnawareAsync(TransportProvider<Socket> worker) { if (ReceiveTimeout == -1) { // Wait for data indefinitely. worker.Provider.BeginReceive(worker.ReceiveBuffer, worker.ReceiveBufferOffset, worker.ReceiveBuffer.Length - worker.ReceiveBufferOffset, SocketFlags.None, ReceivePayloadUnawareAsyncCallback, worker); } else { // Wait for data with a timeout. worker.WaitAsync(ReceiveTimeout, ReceivePayloadUnawareAsyncCallback, worker.Provider.BeginReceive(worker.ReceiveBuffer, worker.ReceiveBufferOffset, worker.ReceiveBuffer.Length - worker.ReceiveBufferOffset, SocketFlags.None, ReceivePayloadUnawareAsyncCallback, worker)); } }
/// <summary> /// Initiate method for asynchronous receive operation of payload data from a single endpoint. /// </summary> private void ReceivePayloadOneAsync(TransportProvider<Socket> worker) { EndPoint client = worker.Provider.RemoteEndPoint; if (ReceiveTimeout == -1) { // Wait for data indefinitely. worker.Provider.BeginReceiveFrom(worker.ReceiveBuffer, worker.ReceiveBufferOffset, worker.ReceiveBuffer.Length, SocketFlags.None, ref client, ReceivePayloadOneAsyncCallback, worker); } else { // Wait for data with a timeout. worker.WaitAsync(ReceiveTimeout, ReceivePayloadOneAsyncCallback, worker.Provider.BeginReceiveFrom(worker.ReceiveBuffer, worker.ReceiveBufferOffset, worker.ReceiveBuffer.Length, SocketFlags.None, ref client, ReceivePayloadOneAsyncCallback, worker)); } }
/// <summary> /// Initiate method for asynchronous receive operation of handshake data. /// </summary> private void ReceiveHandshakeAsync(TransportProvider<Socket> worker) { // Prepare buffer used for receiving data. worker.ReceiveBufferOffset = 0; worker.ReceiveBufferLength = -1; worker.ReceiveBuffer = new byte[ReceiveBufferSize]; // Receive data asynchronously with a timeout. worker.WaitAsync(HandshakeTimeout, ReceiveHandshakeAsyncCallback, worker.Provider.BeginReceive(worker.ReceiveBuffer, worker.ReceiveBufferOffset, worker.ReceiveBuffer.Length, SocketFlags.None, ReceiveHandshakeAsyncCallback, worker)); }
/// <summary> /// Initiate method for asynchronous receive operation of handshake data. /// </summary> private void ReceiveHandshakeAsync(TransportProvider<Socket> worker) { // Receive data asynchronously with a timeout. worker.WaitAsync(HandshakeTimeout, ReceiveHandshakeAsyncCallback, worker.Provider.BeginReceiveFrom(worker.ReceiveBuffer, worker.ReceiveBufferOffset, worker.ReceiveBuffer.Length, SocketFlags.None, ref m_udpServer, ReceiveHandshakeAsyncCallback, worker)); }