up previous next contents
Next: URL Up: Java networking Previous: ServerSocket   Contents

ServerSocket lifecycle

  • A new ServerSocket is created on a port using a ServerSocket() constructor.
  • ServerSocket listens on the port using the accept() method.
  • Uses getInputStream() and/or getOutputStream().
  • Server and client interact using an agreed-upon communication protocol.
  • Either the server or the client (or both) close the connection.
  • The server goes back to listening with the accept() method.


up previous next contents
Next: URL Up: Java networking Previous: ServerSocket   Contents