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
Post a Comment