Пример #1
0
 public bool Connect(IPEndPoint remoteEndPoint)
 {
     TcpClient client = new TcpClient();
     bool connected = false;
     try
     {
         client.Connect(remoteEndPoint);
         socket = new SocketComm(client.Client, true, "Only Client"); // true beause this is the client side
         socket.PacketReceived += new SocketComm.PacketReceivedEventHandler(socket_PacketReceived);
         socket.ClientDisconnected += new Handlers.voidEH(socket_ClientDisconnected);
         connected = true;
     }
     catch (Exception E)
     {
         connected = false;
         System.Diagnostics.Debug.WriteLine(E.StackTrace);
     }
     return connected;
 }
Пример #2
0
        public bool Connect(IPEndPoint remoteEndPoint)
        {
            TcpClient client    = new TcpClient();
            bool      connected = false;

            try
            {
                client.Connect(remoteEndPoint);
                socket = new SocketComm(client.Client, true, "Only Client"); // true beause this is the client side
                socket.PacketReceived     += new SocketComm.PacketReceivedEventHandler(socket_PacketReceived);
                socket.ClientDisconnected += new Handlers.voidEH(socket_ClientDisconnected);
                connected = true;
            }
            catch (Exception E)
            {
                connected = false;
                System.Diagnostics.Debug.WriteLine(E.StackTrace);
            }
            return(connected);
        }