sun.net
Class NetworkClient

java.lang.Object
  extended by sun.net.NetworkClient
Direct Known Subclasses:
HttpClient, TransferProtocolClient

public class NetworkClient
extends Object

This is the base class for network clients.


Field Summary
protected static int defaultConnectTimeout
           
protected static int defaultSoTimeout
           
protected static String encoding
           
 InputStream serverInput
          Buffered stream for reading replies from server.
 PrintStream serverOutput
          Stream for printing to the server.
protected  Socket serverSocket
          Socket for communicating with server.
 
Constructor Summary
NetworkClient()
           
NetworkClient(String host, int port)
          Create connection with host host on port port
 
Method Summary
 void closeServer()
          Close an open connection to the server.
protected  Socket doConnect(String server, int port)
          Return a socket connected to the server, with any appropriate options pre-established
protected  InetAddress getLocalAddress()
           
 void openServer(String server, int port)
          Open a connection to the server.
 boolean serverIsOpen()
          Return server connection status
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serverSocket

protected Socket serverSocket
Socket for communicating with server.


serverOutput

public PrintStream serverOutput
Stream for printing to the server.


serverInput

public InputStream serverInput
Buffered stream for reading replies from server.


defaultSoTimeout

protected static int defaultSoTimeout

defaultConnectTimeout

protected static int defaultConnectTimeout

encoding

protected static String encoding
Constructor Detail

NetworkClient

public NetworkClient(String host,
                     int port)
              throws IOException
Create connection with host host on port port

Throws:
IOException

NetworkClient

public NetworkClient()
Method Detail

openServer

public void openServer(String server,
                       int port)
                throws IOException,
                       UnknownHostException
Open a connection to the server.

Throws:
IOException
UnknownHostException

doConnect

protected Socket doConnect(String server,
                           int port)
                    throws IOException,
                           UnknownHostException
Return a socket connected to the server, with any appropriate options pre-established

Throws:
IOException
UnknownHostException

getLocalAddress

protected InetAddress getLocalAddress()
                               throws IOException
Throws:
IOException

closeServer

public void closeServer()
                 throws IOException
Close an open connection to the server.

Throws:
IOException

serverIsOpen

public boolean serverIsOpen()
Return server connection status