Skip to main content

Issues with IP, java related

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2013-04-02

Hello to you all!
I am new to this forum :)

I am going crazy over an issue with the application I am trying to develop.
It is basically a messenger.

The way its working: I have a server and a client.
The server opens a socket, such as: ServerSocket server=new ServerSocket(2013);
Then, the client requests a connection, with: Socket x=new Socket("",2013)

If I set the "" to localhost (that is it all works well.
But it doesn't work with any other IP.

Can anybody help me?

Thank you,

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2012-11-24

when constructing a socket you pass in the server address and the port number at which the server is waiting for connection as argument.

In your case the server and client are running on the same computer so the server address is localhost(

Passing another argument other than this means you are trying to connect to a server running on another computer with the specified IP address.