Level 177 Level 179
Level 178

Networking: ServerSocket Class Methods

9 words 0 ignored

Ready to learn       Ready to review

Ignore words

Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.

All None

public ServerSocket() throws IOException
Creates an unbound server socket. When using this constructor, use the bind() method when you are ready to bind the server socket
public int getLocalPort()
Returns the port that the server socket is listening on. This method is useful if you passed in 0 as the port number in a constructor and let the server find a port for you.
public Socket accept() throws IOException
Waits for an incoming client. This method blocks until either a client connects to the server on the specified port or the socket times out, assuming that the time-out value has been set using the setSoTimeout() method. Otherwise, this method blocks indefinitely
public void setSoTimeout(int timeout)
Sets the time-out value for how long the server socket waits for a client during the accept().
public Socket()
Creates an unconnected socket. Use the connect() method to connect this socket to a server.
public InetAddress getInetAddress()
This method returns the address of the other computer that this socket is connected to.
public int getPort()
Returns the port the socket is bound to on the remote machine.
public int getLocalPort()
Returns the port the socket is bound to on the local machine.
public void close() throws IOException
Closes the socket, which makes this Socket object no longer capable of connecting again to any server