Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I don't have much experience with socket programming but I running into problems with the software on the client side. If I run the client on the same computer as where the server software is installed it works fine. That is the client can log in with the server no problem but if I install the client software on another computer on the same network when the client attempts to log in I get the following message:
no connection could be made because the target machine actively refused it 127.0.0.1
In both the server and client software I do the following:
IPHostEntry ipHostEntry = Dns.GetHostEntry("localhost");
Does someone know what I am doing wrong?
Thanks Mike
Posted

1 solution

By using "localhost" you've hardcoded it to only work with the client and server on the same host.
You'll need some way for the user to specify to the Client the hostname for the Server an then use that in the connection to the server.
You probably need something like this:
C#
// Establish the remote endpoint for the socket.
// The name of the
// remote device is "host.contoso.com".
IPHostEntry ipHostInfo = Dns.Resolve("host.contoso.com");
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint remoteEP = new IPEndPoint(ipAddress, port);
from MSDN: Asynchronous Client Socket Example[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900