Пример #1
0
 public void RequestConnection()
 {
     try
     {
         m_socket.Connect(m_remoteEndPoint);
     }
     catch (SocketException) {
         Err.AssertWithMsg(false, "Network.Socket.Server.Accept", "Connection refused");
     }
 }
Пример #2
0
        public void Initialize(int portNumber, string ipAddressStr)
        {
            string hostName = Dns.GetHostName();

            // m_ipHostInfo = Dns.GetHostEntry(hostName);
            m_ipHostInfo = Dns.GetHostEntry(ipAddressStr);
            m_ipAddress  = m_ipHostInfo.AddressList[0];
            Console.WriteLine($"HostName: {hostName}, IPAddress: {m_ipAddress}");
            bool returnCode = IPAddress.TryParse(ipAddressStr, out m_ipAddress);

            Err.AssertWithMsg(returnCode, "Network.Socket.Server.Accept", $"IPAddress format is invalid: {m_ipAddress}");
            m_remoteEndPoint = new IPEndPoint(m_ipAddress, portNumber);
        }