sockets - How to listen on IP and Port in Java ? with ServerSocket? -


i'm creating client/server chat (multi-threading) app in java .

i want listen clients on specific port , ip .

when :

serversocket serversocket = new serversocket(port); socket socket = serversocket.accept();      // accept connection  // more code  

does mean ip i'm listening 127.0.0.1 ? i.e. localhost ?

from on constructor of serversocket object , have 3 types of constructors :

public serversocket(int port) throws ioexception public serversocket(int port, int backlog) throws ioexception public serversocket(int port, int backlog, inetaddress bindaddr)  throws ioexception 

what constructor should use , if want clients other ip addresses

this 1 :

public serversocket(int port) throws ioexception 

or 1 :

public serversocket(int port, int backlog, inetaddress bindaddr)  throws ioexception 

?

much appreciated

does mean ip i'm listening 127.0.0.1 ? i.e. localhost ?

no. means listening on ip addresses of host.

what constructor should use if want clients other ip addresses?

this one.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -