API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.net. Socket View Source
Author(s)
unascribed
Since
JDK1.0
Version
1.115, 09/05/07
Serial
Hierarchy
 Object
      Socket
Implements
Subclasses
Description
public class Socket
  This class implements client sockets (also called just "sockets").
Constructors
public Socket ()
  Creates an unconnected socket, with the system-default type of SocketImpl.
public Socket (InetAddress address, int port) throws IOException
  Creates a stream socket and connects it to the specified port number at the specified IP address.
@Deprecated
public Socket (InetAddress host, int port, boolean stream) throws IOException
  Creates a socket and connects it to the specified port number at the specified IP address.
public Socket (InetAddress address, int port, InetAddress localAddr, int localPort) throws IOException
  Creates a socket and connects it to the specified remote address on the specified remote port.
public Socket (Proxy proxy)
  Creates an unconnected socket, specifying the type of proxy, if any, that should be used regardless of any other settings.
private Socket (SocketAddress address, SocketAddress localAddr, boolean stream) throws IOException
protected Socket (SocketImpl impl) throws SocketException
  Creates an unconnected Socket with a user-specified SocketImpl.
public Socket (String host, int port) throws UnknownHostException IOException
  Creates a stream socket and connects it to the specified port number on the named host.
@Deprecated
public Socket (String host, int port, boolean stream) throws IOException
  Creates a stream socket and connects it to the specified port number on the named host.
public Socket (String host, int port, InetAddress localAddr, int localPort) throws IOException
  Creates a socket and connects it to the specified remote host on the specified remote port.
Methods
Hide/Show inherited methods
public void bind (SocketAddress bindpoint) throws IOException
  Binds the socket to a local address.
publicsynchronized void close () throws IOException
  Closes this socket.
public void connect (SocketAddress endpoint) throws IOException
  Connects this socket to the server.
public void connect (SocketAddress endpoint, int timeout) throws IOException
  Connects this socket to the server with a specified timeout value.
pack-private void createImpl (boolean stream) throws SocketException
  Creates the socket implementation.
public SocketChannel getChannel ()
  Returns the unique SocketChannel object associated with this socket, if any.
pack-private SocketImpl getImpl () throws SocketException
  Get the SocketImpl attached to this socket, creating it if necessary.
public InetAddress getInetAddress ()
  Returns the address to which the socket is connected.
public InputStream getInputStream () throws IOException
  Returns an input stream for this socket.
public boolean getKeepAlive () throws SocketException
  Tests if SO_KEEPALIVE is enabled.
public InetAddress getLocalAddress ()
  Gets the local address to which the socket is bound.
public int getLocalPort ()
  Returns the local port to which this socket is bound.
public SocketAddress getLocalSocketAddress ()
  Returns the address of the endpoint this socket is bound to, or null if it is not bound yet.
public boolean getOOBInline () throws SocketException
  Tests if OOBINLINE is enabled.
public OutputStream getOutputStream () throws IOException
  Returns an output stream for this socket.
public int getPort ()
  Returns the remote port to which this socket is connected.
publicsynchronized int getReceiveBufferSize () throws SocketException
  Gets the value of the SO_RCVBUF option for this Socket, that is the buffer size used by the platform for input on this Socket.
public SocketAddress getRemoteSocketAddress ()
  Returns the address of the endpoint this socket is connected to, or null if it is unconnected.
public boolean getReuseAddress () throws SocketException
  Tests if SO_REUSEADDR is enabled.
publicsynchronized int getSendBufferSize () throws SocketException
  Get value of the SO_SNDBUF option for this Socket, that is the buffer size used by the platform for output on this Socket.
public int getSoLinger () throws SocketException
  Returns setting for SO_LINGER.
publicsynchronized int getSoTimeout () throws SocketException
  Returns setting for SO_TIMEOUT.
public boolean getTcpNoDelay () throws SocketException
  Tests if TCP_NODELAY is enabled.
public int getTrafficClass () throws SocketException
  Gets traffic class or type-of-service in the IP header for packets sent from this Socket
public boolean isBound ()
  Returns the binding state of the socket.
public boolean isClosed ()
  Returns the closed state of the socket.
public boolean isConnected ()
  Returns the connection state of the socket.
public boolean isInputShutdown ()
  Returns whether the read-half of the socket connection is closed.
public boolean isOutputShutdown ()
  Returns whether the write-half of the socket connection is closed.
pack-privatefinal void postAccept ()
set the flags after an accept() call.
public void sendUrgentData (int data) throws IOException
  Send one byte of urgent data on the socket.
pack-private void setBound ()
pack-private void setConnected ()
pack-private void setCreated ()
pack-private void setImpl ()
  Sets impl to the system-default type of SocketImpl.
public void setKeepAlive (boolean on) throws SocketException
  Enable/disable SO_KEEPALIVE.
public void setOOBInline (boolean on) throws SocketException
  Enable/disable OOBINLINE (receipt of TCP urgent data) By default, this option is disabled and TCP urgent data received on a socket is silently discarded.
public void setPerformancePreferences (int connectionTime, int latency, int bandwidth)
  Sets performance preferences for this socket.
publicsynchronized void setReceiveBufferSize (int size) throws SocketException
  Sets the SO_RCVBUF option to the specified value for this Socket.
public void setReuseAddress (boolean on) throws SocketException
  Enable/disable the SO_REUSEADDR socket option.
publicsynchronized void setSendBufferSize (int size) throws SocketException
  Sets the SO_SNDBUF option to the specified value for this Socket.
publicstaticsynchronized void setSocketImplFactory (SocketImplFactory fac) throws IOException
  Sets the client socket implementation factory for the application.
public void setSoLinger (boolean on, int linger) throws SocketException
  Enable/disable SO_LINGER with the specified linger time in seconds.
publicsynchronized void setSoTimeout (int timeout) throws SocketException
  Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
public void setTcpNoDelay (boolean on) throws SocketException
  Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).
public void setTrafficClass (int tc) throws SocketException
  Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket.
public void shutdownInput () throws IOException
  Places the input stream for this socket at "end of stream".
public void shutdownOutput () throws IOException
  Disables the output stream for this socket.
public String toString ()
  Converts this socket to a String.
Fields
Hide/Show inherited fields
pack-private SocketImpl impl
The implementation of this Socket.
Nested Classes
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar