Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to write a server (and client) application that will run in the following way:

Say you and I both have our machines connected to the same router in the same house.
I have my server running on my machine, and your machine connects to my server and say for example transfers some files.

I have managed to get this running on the same machine (ie server and client are both on one machine), however I have not been able to connect to the server on my machine from any other machine in the house.

Here's a code snippet from my server application:

C#
this.tcpListener = new TcpListener(IPAddress.Any, 3000);
this.listenThread = new Thread(new ThreadStart(ListenForClients));
this.listenThread.Start();


And here is my client application:

C#
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 3000);
Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);


Any help is appreciated. Thank you all in advance.
Posted
Updated 18-Nov-11 12:14pm
v2
Comments
Sergey Alexandrovich Kryukov 18-Nov-11 18:40pm    
Not clear what exactly is your problem.
--SA

Well to start with the address "127.0.0.1" will ONLY work on the machine the server is also on (it's the local loop back, so using on a client machine will send it back to the client machine). So you will need to find the IP of the machine the server is on.

If with the proper IP address it still doesn't work, make sure your router is properly configured to forward it to the server machine (Google how-to's, they exist for every router I've worked with)
 
Share this answer
 
v2
Some ideas from my past answers might help you:
Multple clients from same port Number[^],
automatic updater triggered via server[^].

—SA
 
Share this answer
 
You can not access the server computer from the another machine when you're trying the "127.0.0.1" ip address. It's only using your local computer. If you connected to a router in this example(your home network), an address is assigned to your computer. For example; 192.168.2.2, 192.168.2.3 ex.

Try one of these in your client code.
 
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