Problem with IP address on chat application

georgesmith

New member
Joined
Dec 17, 2007
Messages
2
Programming Experience
Beginner
Hello All,

I have coded a chat application that works on the IP/TCP ports.
There will be a admin - server - client.

Admin is moderator of the chat room.

Server is server side application

Client is the end user.

But here is my problem. I cant open Admin and Client on the same computer with same IP address.

The application uses IP and ports to connect to each other.

Can anyone help me in this.

Thanking you in advance.

Georgesmith
 
The problem is you try to bind two sockets to same IP/port combination, only one is allowed at a time. Your computer has only one IP but thousands of ports. For example with TcpListener you specify which port to listen, so this IP/port is then occupied. For TcpClient do notice the difference in constructor parameters, if you specify IPEndPoint this is the socket to bind locally (parameter is named localEP), if you choose the hostname/port constructor this is opposite; it means where you connect to. Both when using the latter constructor, or the parameterless constructor and Connect method TcpClient binds to any free port locally.
 
Back
Top