java.net.Socket (class)
Constructors:
Socket(String host, int port);
Socket(InetAddress addr, int port);
Socket(String host, int port, InetAddress lAddr, int lPort);
Socket(InetAddress addr, int port, InetAddress lAddr, int lPort);
General Description: This is the basic communication interface (TCP) for all network traffic.
Parent Class: Object
Methods
void close(); Close the socket.
InetAddress getInetAddress(); Get the host address of the peer.
InputStream getInputStream(); Get the InputStream for receiving messages.
boolean getKeepAlive() ;
void setKeepAlive(boolean on); Keep the connection alive.
InetAddress getLocalAddress(); Get the local address the socket is connected to.
int getLocalPort(); Get the local port.
OutputStream getOutputStream(); Get the OutputStream for sending messages.
int getPort(); Get the peer's port number.
int getReceiveBufferSize();
void setReceiveBufferSize(int size); Get/set receive-buffer's size.
int getSendBufferSize();
void setSendBufferSize(int size); Get/set send-buffer's size.
int getSoLinger();
void setSoLinger(boolean on, int linger); Get/set the socket linger time (in seconds).
int getSoTimeout();
void setSoTimeout(int timeout); Get/set the timeout for I/O. If enabled, reading the pipe aborts after specified time.
boolean getTcpNoDelay();
void setTcpNoDelay(boolean on); Enable/disable the Nagle algorithm which determines the process for sending information. If disabled, the computer sends the data before it receives any confirmation.
void shutdownInput(); Close the input channel.
void shutdownOutput(); Close the output channel.
Exceptions Thrown
IOException, SocketException,