Inheritance: RemoteAddress
        public ClientConnection(Socket sock)
            : base(sock)
        {
            if (SlotId == 0)
                SlotId = -1;

            var remoteEndPoint = (IPEndPoint)sock.RemoteEndPoint;
            _remoteAddress = new TcpAddress(remoteEndPoint.Address, remoteEndPoint.Port);

            sock.LingerState = new LingerOption(true, 10);

            var ctx = new HookContext
            {
                Connection = this
            };

            var args = new HookArgs.NewConnection();

            HookPoints.NewConnection.Invoke(ref ctx, ref args);

            if (ctx.CheckForKick())
                return;

            _isReceiving = true; //The connection was established, so we can begin reading
        }
        public ClientConnection(Socket sock)
            : base(sock)
        {
            if (SlotId == 0)
                SlotId = -1;

            var remoteEndPoint = (IPEndPoint)sock.RemoteEndPoint;
            _remoteAddress = new TcpAddress(remoteEndPoint.Address, remoteEndPoint.Port);

            //            sock.LingerState = new LingerOption(true, 10);

            //            var ctx = new HookContext
            //            {
            //                Connection = this
            //            };
            //
            //            var args = new HookArgs.NewConnection();
            //
            //            HookPoints.NewConnection.Invoke(ref ctx, ref args);
            //
            //            if (ctx.CheckForKick())
            //                return;

            StartReading();
        }
Exemplo n.º 3
0
 public static void TcpClientLoop(object threadContext)
 {
     RemoteAddress address = new TcpAddress(Netplay.ServerIP, Netplay.ListenPort);
     Netplay.ClientLoopSetup(address);
     Main.menuMode = 14;
     bool flag = true;
     while (flag)
     {
         flag = false;
         try
         {
             Netplay.Connection.Socket.Connect(new TcpAddress(Netplay.ServerIP, Netplay.ListenPort));
             flag = false;
         }
         catch
         {
             if (!Netplay.disconnect && Main.gameMenu)
             {
                 flag = true;
             }
         }
     }
     Netplay.InnerClientLoop();
 }
 void ISocket.Connect(RemoteAddress address)
 {
     _remoteAddress = address as TcpAddress;
     var sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     sock.Connect(_remoteAddress.Address, _remoteAddress.Port);
     SetSocket(sock);
 }