Esempio n. 1
0
        public void StartConnect(string Ip, int Port, CurSocket cur, int CMD = 0, byte[] temp = null, BufferData bufdt = null)
        {
            CurTCP     = cur;
            mtcpClient = new TcpClient();
            BufferData BUF = new BufferData();

            if (cur == CurSocket.Game_)
            {
                Debuger.Log("当前链接的服务器是游戏服务器" + Ip + " " + Port);
                mtcpClient.BeginConnect(Ip, Port, ConnectOK, null);
            }
            else
            {
                Debuger.Log("当前链接的服务器是登陆服务器");
                IP_   = Ip;
                Port_ = Port;
                if (bufdt != null)
                {
                    BUF.Cmd    = CMD;
                    BUF.Buf    = temp;
                    BUF.Length = temp.Length;
                    BUF.Bufdt  = bufdt;
                }
                mtcpClient.BeginConnect(Ip, Port, ConnectOK, BUF);
            }
        }
Esempio n. 2
0
        private NetworkSocket FindSocket(MultiValueDictionary <UInt64, NetworkSocket> List, int ProcessId, UInt32 ProtocolType, IPAddress LocalAddress, UInt16 LocalPort, IPAddress RemoteAddress, UInt16 RemotePort, NetworkSocket.MatchMode Mode)
        {
            UInt64 HashID = NetworkSocket.MkHash(ProcessId, ProtocolType, LocalAddress, LocalPort, RemoteAddress, RemotePort);

            List <NetworkSocket> Matches = List.GetValues(HashID, false);

            if (Matches != null)
            {
                foreach (NetworkSocket CurSocket in Matches)
                {
                    if (CurSocket.Match(ProcessId, ProtocolType, LocalAddress, LocalPort, RemoteAddress, RemotePort, Mode))
                    {
                        return(CurSocket);
                    }
                }
            }

            return(null);
        }