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)

    Deprecated, for removal: This API element is subject to removal in a future version.

    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.

    Methods declared in class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Creates and returns a copy of this object.

    boolean

    Indicates whether some other object is "equal to" this one.

    protected void

    Deprecated, for removal: This API element is subject to removal in a future version.

    Returns the runtime class of this Object.

    int

    Returns a hash code value for this object.

    final void

    Wakes up a single thread that is waiting on this object's monitor.

    final void

    Wakes up all threads that are waiting on this object's monitor.

    final void

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

    final void

    wait(long timeoutMillis)

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

    final void

    wait(long timeoutMillis, int nanos)

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

  • 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