Exemple #1
0
 /// <summary>
 /// Called when the socket completes sending a request to connect to an IP end point.
 /// </summary>
 /// <param name="ar">The asynchronous result object for the asynchronous method.</param>
 private void OnSocketSendConnect(IAsyncResult ar)
 {
     try
     {
         socket.EndSend(ar);
         socket.BeginReceive(buffer, 0, 5, SocketFlags.None, OnSocketReceiveConnect, socket);
     }
     catch
     {
         if (callback != null)
         {
             callback(false);
         }
     }
 }
        /// <summary>
        /// Called when the destination socket has completed sending data.
        /// </summary>
        /// <param name="ar">The asynchronous result object for the asynchronous method.</param>
        private void OnDestinationSocketSent(IAsyncResult ar)
        {
            try
            {
                if (destinationSocket != null)
                {
                    int dispatched = destinationSocket.EndSend(ar);

                    if (dispatched > 0)
                    {
                        if (connection != null && connection.Socket != null)
                        {
                            connection.Socket.BeginReceive(connectionBuffer, 0, connectionBuffer.Length, SocketFlags.None, OnConnectionSocketReceive, connection.Socket);
                        }

                        return;
                    }
                }
            }
            catch { }

            Dispose();
        }