Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry("localhost");
- IPAddress ipAddress = ipHostInfo.AddressList[0];
- IPEndPoint remoteEP = new IPEndPoint(ipAddress, Port);
- Sock = new Socket(remoteEP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
- Sock.BeginConnect(remoteEP, new AsyncCallback(ConnectCallback), Sock);
- System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it [::1]:7777
- at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
- at NotifierClient.AsynchronousClient.ConnectCallback(IAsyncResult ar) in *** :line 156
- client.EndConnect(ar);
- IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry("localhost");
- IPAddress ipAddress = null;
- foreach(var addr in ipHostInfo.AddressList)
- {
- if(addr.AddressFamily == AddressFamily.InterNetwork) // this is IPv4
- {
- ipAddress = addr;
- break;
- }
- }
- // at this point, ipAddress is either going to be set to the first IPv4 address
- // or it is going to be null if no IPv4 address was found in the list
- if(ipAddress == null)
- throw new Exception("Error finding an IPv4 address for localhost");
- IPEndPoint remoteEP = new IPEndPoint(ipAddress, Port);
- Sock = new Socket(remoteEP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
- Sock.BeginConnect(remoteEP, new AsyncCallback(ConnectCallback), Sock);
- IPHostEntry ipHostInfo = Dns.GetHostEntry("localhost");
- IPAddress ipAddress = ipHostInfo.AddressList[1];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement