<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.net.ServerSocket
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.net.html">This Package</a>  <a href="java.net.MulticastSocket.html#_top_">Previous</a>  <a href="java.net.Socket.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.net.ServerSocket
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----java.net.ServerSocket
</pre>
<hr>
<dl>
  <dt> public class <b>ServerSocket</b>
  <dt> extends <a href="java.lang.Object.html#_top_">Object</a>
</dl>
This class implements server sockets. A server socket waits for 
 requests to come in over the network. It performs some operation 
 based on that request, and then possibly returns a result to the requester.
 <p>
 The actual work of the server socket is performed by an instance 
 of the <code>SocketImpl</code> class. An application can 
 change the socket factory that creates the socket 
 implementation to configure itself to create sockets 
 appropriate to the local firewall.
<p>
<dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.net.SocketImpl.html#_top_">SocketImpl</a>, <a href="#setSocketFactory(java.net.SocketImplFactory)">setSocketFactory</a>
</dl>
<hr>
<a name="index"></a>
<h2>
  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#ServerSocket(int)"><b>ServerSocket</b></a>(int)
  <dd>  Creates a server socket on a specified port.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#ServerSocket(int, int)"><b>ServerSocket</b></a>(int, int)
  <dd>  Creates a server socket and binds it to the specified local port 
 number.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#ServerSocket(int, int, java.net.InetAddress)"><b>ServerSocket</b></a>(int, int, InetAddress)
  <dd> 
 Create a server with the specified port, listen backlog, and 
 local IP address to bind to.
</dl>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#accept()"><b>accept</b></a>()
  <dd>  Listens for a connection to be made to this socket and accepts 
 it.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#close()"><b>close</b></a>()
  <dd>  Closes this socket.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getInetAddress()"><b>getInetAddress</b></a>()
  <dd>  Returns the local address of this server socket.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getLocalPort()"><b>getLocalPort</b></a>()
  <dd>  Returns the port on which this socket is listening.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getSoTimeout()"><b>getSoTimeout</b></a>()
  <dd> Retrive setting for SO_TIMEOUT.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#implAccept(java.net.Socket)"><b>implAccept</b></a>(Socket)
  <dd>  Subclasses of ServerSocket use this method to override accept()
 to return their own subclass of socket.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setSocketFactory(java.net.SocketImplFactory)"><b>setSocketFactory</b></a>(SocketImplFactory)
  <dd>  Sets the server socket implementation factory for the 
 application.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setSoTimeout(int)"><b>setSoTimeout</b></a>(int)
  <dd> Enable/disable SO_TIMEOUT with the specified timeout, in
  milliseconds.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#toString()"><b>toString</b></a>()
  <dd>  Returns the implementation address and implementation port of 
 this socket as a <code>String</code>.
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="ServerSocket"></a>
<a name="ServerSocket(int)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>ServerSocket</b>
<pre>
 public ServerSocket(int port) throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Creates a server socket on a specified port. A port of 
 <code>0</code> creates a socket on any free port. 
 <p>
 The maximum queue length for incoming connection indications (a 
 request to connect) is set to <code>50</code>. If a connection 
 indication arrives when the queue is full, the connection is refused.
 <p>
 If the application has specified a server socket factory, that 
 factory's <code>createSocketImpl</code> method is called to create 
 the actual socket implementation. Otherwise a "plain" socket is created.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> port - the port number, or <code>0</code> to use any
                   free port.
    <dt> <b>Throws:</b> <a href="java.io.IOException.html#_top_">IOException</a>
    <dd> if an I/O error occurs when opening the socket.
    <dt> <b>See Also:</b>
    <dd> <a href="java.net.SocketImpl.html#_top_">SocketImpl</a>, <a href="java.net.SocketImplFactory.html#createSocketImpl()">createSocketImpl</a>, <a href="#setSocketFactory(java.net.SocketImplFactory)">setSocketFactory</a>
  </dl></dd>
</dl>
<a name="ServerSocket(int, int)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>ServerSocket</b>
<pre>
 public ServerSocket(int port,
                     int backlog) throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Creates a server socket and binds it to the specified local port 
 number. A port number of <code>0</code> creates a socket on any 
 free port. 
 <p>
 The maximum queue length for incoming connection indications (a 
 request to connect) is set to the <code>count</code> parameter. If 
 a connection indication arrives when the queue is full, the 
 connection is refused. 
 <p>
 If the application has specified a server socket factory, that 
 factory's <code>createSocketImpl</code> method is called to create 
 the actual socket implementation. Otherwise a "plain" socket is created.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> port - the specified port, or <code>0</code> to use
                      any free port.
    <dd> backlog - the maximum length of the queue.
    <dt> <b>Throws:</b> <a href="java.io.IOException.html#_top_">IOException</a>
    <dd> if an I/O error occurs when opening the socket.
    <dt> <b>See Also:</b>
    <dd> <a href="java.net.SocketImpl.html#_top_">SocketImpl</a>, <a href="java.net.SocketImplFactory.html#createSocketImpl()">createSocketImpl</a>, <a href="#setSocketFactory(java.net.SocketImplFactory)">setSocketFactory</a>
  </dl></dd>
</dl>
<a name="ServerSocket(int, int, java.net.InetAddress)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>ServerSocket</b>
<pre>
 public ServerSocket(int port,
                     int backlog,
                     <a href="java.net.InetAddress.html#_top_">InetAddress</a> bindAddr) throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Create a server with the specified port, listen backlog, and 
 local IP address to bind to.  The <i>bindAddr</i> argument
 can be used on a multi-homed host for a ServerSocket that
 will only accept connect requests to one of its addresses.
 If <i>bindAddr</i> is null, it will default accepting
 connections on any/all local addresses.
 The port must be between 0 and 65535, inclusive.
 <P>
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> port - the local TCP port
    <dd> backlog - the listen backlog
    <dd> bindAddr - the local InetAddress the server will bind to
    <dt> <b>See Also:</b>
    <dd> SocketConstants, SocketOption, <a href="java.net.SocketImpl.html#_top_">SocketImpl</a>, 1
  </dl></dd>
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="getInetAddress()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getInetAddress"><b>getInetAddress</b></a>
<pre>
 public <a href="java.net.InetAddress.html#_top_">InetAddress</a> getInetAddress()
</pre>
<dl>
  <dd> Returns the local address of this server socket.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the address to which this socket is connected,
          or <code>null</code> if the socket is not yet connected.
  </dl></dd>
</dl>
<a name="getLocalPort()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getLocalPort"><b>getLocalPort</b></a>
<pre>
 public int getLocalPort()
</pre>
<dl>
  <dd> Returns the port on which this socket is listening.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the port number to which this socket is listening.
  </dl></dd>
</dl>
<a name="accept()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="accept"><b>accept</b></a>
<pre>
 public <a href="java.net.Socket.html#_top_">Socket</a> accept() throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Listens for a connection to be made to this socket and accepts 
 it. The method blocks until a connection is made.
<p>
  <dd><dl>
    <dt> <b>Throws:</b> <a href="java.io.IOException.html#_top_">IOException</a>
    <dd> if an I/O error occurs when waiting for a
               connection.
  </dl></dd>
</dl>
<a name="implAccept(java.net.Socket)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="implAccept"><b>implAccept</b></a>
<pre>
 protected final void implAccept(<a href="java.net.Socket.html#_top_">Socket</a> s) throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Subclasses of ServerSocket use this method to override accept()
 to return their own subclass of socket.  So a FooServerSocket
 will typically hand this method an <i>empty</i> FooSocket().  On
 return from implAccept the FooSocket will be connected to a client.
<p>
</dl>
<a name="close()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="close"><b>close</b></a>
<pre>
 public void close() throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Closes this socket.
<p>
  <dd><dl>
    <dt> <b>Throws:</b> <a href="java.io.IOException.html#_top_">IOException</a>
    <dd> if an I/O error occurs when closing the socket.
  </dl></dd>
</dl>
<a name="setSoTimeout(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setSoTimeout"><b>setSoTimeout</b></a>
<pre>
 public synchronized void setSoTimeout(int timeout) throws <a href="java.net.SocketException.html#_top_">SocketException</a>
</pre>
<dl>
  <dd> Enable/disable SO_TIMEOUT with the specified timeout, in
  milliseconds.  With this option set to a non-zero timeout,
  a call to accept() for this ServerSocket
  will block for only this amount of time.  If the timeout expires,
  a <B>java.io.InterruptedIOException</B> is raised, though the
  ServerSocket is still valid.  The option <B>must</B> be enabled
  prior to entering the blocking operation to have effect.  The 
  timeout must be > 0.
  A timeout of zero is interpreted as an infinite timeout.
<p>
</dl>
<a name="getSoTimeout()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getSoTimeout"><b>getSoTimeout</b></a>
<pre>
 public synchronized int getSoTimeout() throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Retrive setting for SO_TIMEOUT.  0 returns implies that the
  option is disabled (i.e., timeout of infinity).
<p>
</dl>
<a name="toString()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="toString"><b>toString</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> toString()
</pre>
<dl>
  <dd> Returns the implementation address and implementation port of 
 this socket as a <code>String</code>.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> a string representation of this socket.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.lang.Object.html#toString()">toString</a> in class <a href="java.lang.Object.html#_top_">Object</a>
  </dl></dd>
</dl>
<a name="setSocketFactory(java.net.SocketImplFactory)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setSocketFactory"><b>setSocketFactory</b></a>
<pre>
 public static synchronized void setSocketFactory(<a href="java.net.SocketImplFactory.html#_top_">SocketImplFactory</a> fac) throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Sets the server socket implementation factory for the 
 application. The factory can be specified only once. 
 <p>
 When an application creates a new server socket, the socket 
 implementation factory's <code>createSocketImpl</code> method is 
 called to create the actual socket implementation.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> fac - the desired factory.
    <dt> <b>Throws:</b> <a href="java.io.IOException.html#_top_">IOException</a>
    <dd> if an I/O error occurs when setting the
               socket factory.
    <dt> <b>Throws:</b> <a href="java.net.SocketException.html#_top_">SocketException</a>
    <dd> if the factory has already been defined.
    <dt> <b>See Also:</b>
    <dd> <a href="java.net.SocketImplFactory.html#createSocketImpl()">createSocketImpl</a>
  </dl></dd>
</dl>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.net.html">This Package</a>  <a href="java.net.MulticastSocket.html#_top_">Previous</a>  <a href="java.net.Socket.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
