Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bind to 127.0.0.2

I'm running a client/server application locally on my Windows XP PC and for testing purposes I want to run multiple clients.

The server has a configuration file containing the IP addresses of the clients that can connect; in the real world, these would all be on separate hosts with separate IP addresses.

Currently I am able to test locally with a single client which binds to 127.0.0.1 however because I can only have one client-IP mapping in the server configuration (that's how the system works and can't be redesigned!) I can only run one client on my development PC.

I've tried to start another client application bound to 127.0.0.2 connecting to the server which is bound to 0.0.0.0 however the server thinks that the client is connecting from 127.0.0.1 again and so rejects what it believes is a second connection from the first client.

Can anyone suggest a way to get around this problem? I believe I could run one more client bound to the external IP address of the PC but I'd really like to be able to run multiple.

I know I could use VirtualBox or similar to run new instances but I'd like all of the client applications to be running in the Visual Studio debugger.

Any help greatly appreciated!

Nick.

PS. Not sure if it matters but the applications are written in C++ using standard winsock sockets.

like image 383
Nick Avatar asked Mar 11 '11 10:03

Nick


People also ask

What is IP 127.0 0.1 called?

Localhost is the default name of the computer you are working on. The term is a pseudo name for 127.0. 0.1, the IP address of the local computer. This IP address allows the machine to connect to and communicate with itself.

What is loopback IP address 127.0 0.1 indicates?

The IP address 127.0. 0.1 is called a loopback address. Packets sent to this address never reach the network but are looped through the network interface card only. This can be used for diagnostic purposes to verify that the internal path through the TCP/IP protocols is working.

Is 127.0 0.1 and localhost the same?

Localhost is often considered synonymous with the IP address 127.0. 0.1.

What is the address range 127.0 0.0 used for?

Network 127.0. 0.0 is reserved for IP traffic local to your host. Usually, address 127.0. 0.1 will be assigned to a special interface on your host, the loopback interface, which acts like a closed circuit.


2 Answers

You might be able to create more loopback interfaces. See the chosen answer to How do you create a virtual network interface on Windows?

like image 79
Ilkka Avatar answered Sep 22 '22 00:09

Ilkka


AFAIK Windows 7 (maybe Vista too) lets you add multiple IP addresses to a single interface (card).

like image 39
vbence Avatar answered Sep 25 '22 00:09

vbence