public void RequestConnection() { try { m_socket.Connect(m_remoteEndPoint); } catch (SocketException) { Err.AssertWithMsg(false, "Network.Socket.Server.Accept", "Connection refused"); } }
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); }