예제 #1
0
파일: TcpServer.cs 프로젝트: avs009/gsf
        /// <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));

            }
        }
예제 #2
0
파일: UdpServer.cs 프로젝트: avs009/gsf
 /// <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));
     }
 }
예제 #3
0
파일: TcpServer.cs 프로젝트: avs009/gsf
 /// <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));
 }
예제 #4
0
파일: UdpClient.cs 프로젝트: avs009/gsf
 /// <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));
 }