Skip to main content

Issues with IP, java related

1 reply [Last post]
Raduh
Offline
Joined: 2013-04-02
Points: 0

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("ra.nd.om.ip",2013)

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

Can anybody help me?

Thank you,
Radu

Reply viewing options

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

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(127.0.0.1).

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