Example usage for Java java.net Socket fields, constructors, methods, implement or subclass
The text is from its open source code.
Socket(String host, int port) Creates a stream socket and connects it to the specified port number on the named host. | |
Socket(InetAddress address, int port) Creates a stream socket and connects it to the specified port number at the specified IP address. | |
Socket(String host, int port, boolean stream) Creates a stream socket and connects it to the specified port number on the named host. | |
Socket(InetAddress host, int port, boolean stream) Creates a socket and connects it to the specified port number at the specified IP address. | |
Socket(SocketAddress address, SocketAddress localAddr, boolean stream) | |
Socket(String host, int port, InetAddress localAddr, int localPort) Creates a socket and connects it to the specified remote host on the specified remote port. | |
Socket(InetAddress address, int port, InetAddress localAddr, int localPort) Creates a socket and connects it to the specified remote address on the specified remote port. | |
Socket(Proxy proxy) Creates an unconnected socket, specifying the type of proxy, if any, that should be used regardless of any other settings. | |
Socket(SocketImpl impl) Creates an unconnected Socket with a user-specified SocketImpl. | |
Socket() Creates an unconnected Socket. |
void | bind(SocketAddress bindpoint) Binds the socket to a local address. |
void | close() Closes this socket. |
void | connect(SocketAddress endpoint) Connects this socket to the server. |
void | connect(SocketAddress endpoint, int timeout) Connects this socket to the server with a specified timeout value. |
SocketChannel | getChannel() Returns the unique java.nio.channels.SocketChannel SocketChannel object associated with this socket, if any. |
Class> | getClass() Returns the runtime class of this Object . |
InetAddress | getInetAddress() Returns the address to which the socket is connected. |
InputStream | getInputStream() Returns an input stream for this socket. |
boolean | getKeepAlive() Tests if SocketOptions#SO_KEEPALIVE SO_KEEPALIVE is enabled. |
InetAddress | getLocalAddress() Gets the local address to which the socket is bound. |
int | getLocalPort() Returns the local port number to which this socket is bound. |
SocketAddress | getLocalSocketAddress() Returns the address of the endpoint this socket is bound to. |
boolean | getOOBInline() Tests if SocketOptions#SO_OOBINLINE SO_OOBINLINE is enabled. |
OutputStream | getOutputStream() Returns an output stream for this socket. |
int | getPort() Returns the remote port number to which this socket is connected. |
int | getReceiveBufferSize() Gets the value of the SocketOptions#SO_RCVBUF SO_RCVBUF option for this Socket , that is the buffer size used by the platform for input on this Socket . |
SocketAddress | getRemoteSocketAddress() Returns the address of the endpoint this socket is connected to, or null if it is unconnected. |
boolean | getReuseAddress() Tests if SocketOptions#SO_REUSEADDR SO_REUSEADDR is enabled. |
int | getSendBufferSize() Get value of the SocketOptions#SO_SNDBUF SO_SNDBUF option for this Socket , that is the buffer size used by the platform for output on this Socket . |
int | getSoLinger() Returns setting for SocketOptions#SO_LINGER SO_LINGER . |
int | getSoTimeout() Returns setting for SocketOptions#SO_TIMEOUT SO_TIMEOUT . |
boolean | getTcpNoDelay() Tests if SocketOptions#TCP_NODELAY TCP_NODELAY is enabled. |
int | getTrafficClass() Gets traffic class or type-of-service in the IP header for packets sent from this Socket As the underlying network implementation may ignore the traffic class or type-of-service set using #setTrafficClass(int) this method may return a different value than was previously set using the #setTrafficClass(int) method on this Socket. |
int | hashCode() Returns a hash code value for the object. |
boolean | isBound() Returns the binding state of the socket. |
boolean | isClosed() Returns the closed state of the socket. |
boolean | isConnected() Returns the connection state of the socket. |
boolean | isInputShutdown() Returns whether the read-half of the socket connection is closed. |
boolean | isOutputShutdown() Returns whether the write-half of the socket connection is closed. |
void | sendUrgentData(int data) Send one byte of urgent data on the socket. |
void | setKeepAlive(boolean on) Enable/disable SocketOptions#SO_KEEPALIVE SO_KEEPALIVE . |
void | setOOBInline(boolean on) Enable/disable SocketOptions#SO_OOBINLINE SO_OOBINLINE (receipt of TCP urgent data) By default, this option is disabled and TCP urgent data received on a socket is silently discarded. |
void | setPerformancePreferences(int connectionTime, int latency, int bandwidth) Sets performance preferences for this socket. |
void | setReceiveBufferSize(int size) Sets the SocketOptions#SO_RCVBUF SO_RCVBUF option to the specified value for this Socket . |
void | setReuseAddress(boolean on) Enable/disable the SocketOptions#SO_REUSEADDR SO_REUSEADDR socket option. |
void | setSendBufferSize(int size) Sets the SocketOptions#SO_SNDBUF SO_SNDBUF option to the specified value for this Socket . |
void | setSocketImplFactory(SocketImplFactory fac) Sets the client socket implementation factory for the application. |
void | setSoLinger(boolean on, int linger) Enable/disable SocketOptions#SO_LINGER SO_LINGER with the specified linger time in seconds. |
void | setSoTimeout(int timeout) Enable/disable SocketOptions#SO_TIMEOUT SO_TIMEOUT with the specified timeout, in milliseconds. |
void | setTcpNoDelay(boolean on) Enable/disable SocketOptions#TCP_NODELAY TCP_NODELAY (disable/enable Nagle's algorithm). |
void | setTrafficClass(int tc) Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket. |
void | shutdownInput() Places the input stream for this socket at "end of stream". |
void | shutdownOutput() Disables the output stream for this socket. |
String | toString() Converts this socket to a String . |
void | wait() Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |