All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
SSLServerSocket

  • Constructor Summary

    Constructors

    Creates an unbound server socket.

    ServerSocket(int port)

    Creates a server socket, bound to the specified port.

    ServerSocket(int port, int backlog)

    Creates a server socket and binds it to the specified local port number, with the specified backlog.

    Create a server with the specified port, listen backlog, and local IP address to bind to.

    protected

    Creates a server socket with a user-specified SocketImpl.

  • Method Summary

    accept()

    Listens for a connection to be made to this socket and accepts it.

    void

    Binds the ServerSocket to a specific address (IP address and port number).

    void

    Binds the ServerSocket to a specific address (IP address and port number).

    void

    close()

    Returns the local address of this server socket.

    int

    Returns the port number on which this socket is listening.

    Returns the address of the endpoint this socket is bound to.

    <T> T

    Returns the value of a socket option.

    int

    Gets the value of the SO_RCVBUF option for this ServerSocket, that is the proposed buffer size that will be used for Sockets accepted from this ServerSocket.

    boolean

    int

    Retrieve setting for SO_TIMEOUT. 0 returns implies that the option is disabled (i.e., timeout of infinity).

    protected final void

    Subclasses of ServerSocket use this method to override accept() to return their own subclass of socket.

    boolean

    isBound()

    Returns the binding state of the ServerSocket.

    boolean

    isClosed()

    Returns the closed state of the ServerSocket.

    Sets the value of a socket option.

    void

    setPerformancePreferences(int connectionTime, int latency, int bandwidth)

    Sets performance preferences for this ServerSocket.

    void

    setReceiveBufferSize(int size)

    Sets a default proposed value for the SO_RCVBUF option for sockets accepted from this ServerSocket.

    void

    setReuseAddress(boolean on)

    static void

    void

    setSoTimeout(int timeout)

    Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.

    Returns a set of the socket options supported by this server socket.

    toString()

    Returns the implementation address and implementation port of this socket as a String.

  • Constructor Details

    • ServerSocket

    • ServerSocket

    • ServerSocket

    • ServerSocket

    • ServerSocket

  • Method Details

    • bind

    • bind

    • getInetAddress

    • getLocalPort

    • getLocalSocketAddress

    • accept

    • implAccept

    • close

    • getChannel

    • isBound

    • isClosed

    • setSoTimeout

    • getSoTimeout

    • setReuseAddress

    • getReuseAddress

    • toString

    • setSocketFactory

    • setReceiveBufferSize

    • getReceiveBufferSize

    • setPerformancePreferences

    • setOption

    • getOption

    • supportedOptions