All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.jaw.impl.adaptor.http.AdaptorSocket

java.lang.Object
   |
   +----com.sun.jaw.impl.adaptor.comm.AdaptorSocket
           |
           +----com.sun.jaw.impl.adaptor.http.AdaptorSocket

public class AdaptorSocket
extends AdaptorSocket
This class provides methods for actions required for client and server side sockets. The actions are used for an HTTP-based adaptor using TCP.


Constructor Index

 o AdaptorSocket()
Default constructor.
 o AdaptorSocket(int)
Constructor.

Method Index

 o createClientSocket()
Creates a client socket.
 o createServerSocket(int)
Creates a server socket using the specified port.
 o doBind()
Binds this adaptor socket to a specified port.
 o doConnect(String, int)
Connects this adaptor socket to a specified server and port.
 o doDisconnect()
Disconnects this adaptor socket.
 o doGetInputStream()
Returns an input stream for this adaptor socket.
 o doReceive()
Waits for an incoming message.
 o doSend(String, byte[])
Sends the specified header and content to the peer.
 o doUnbind()
Unbinds this adaptor socket.
 o getLocalAddress()
Returns the local IP address.
 o getLocalPort()
Returns the local port number.
 o getProtocol()
Returns the name of the protocol used.
 o getRemoteAddress()
Returns the remote IP address.
 o getRemotePort()
Returns the remote port number.
 o toString()
Returns the implementation address and implementation port of this socket as a string.

Constructors

 o AdaptorSocket
 public AdaptorSocket()
Default constructor. Creates an instance of an HTTP/TCP adaptor socket.

 o AdaptorSocket
 public AdaptorSocket(int port)
Constructor. Creates an instance of an HTTP/TCP adaptor socket using a specified port.

Parameters:
port - The port number.

Methods

 o createServerSocket
 public AdaptorSocket createServerSocket(int port)
Creates a server socket using the specified port.

Parameters:
port - The port number.
Returns:
An instance of the com.sun.jaw.impl.adaptor.comm.AdaptorSocket class, using the specified port.
Overrides:
createServerSocket in class AdaptorSocket
 o createClientSocket
 public AdaptorSocket createClientSocket()
Creates a client socket. No port is provided as the client does not "bind".

Returns:
An instance of the com.sun.jaw.impl.adaptor.comm.AdaptorSocket class.
Overrides:
createClientSocket in class AdaptorSocket
 o getProtocol
 public String getProtocol()
Returns the name of the protocol used.

Returns:
The string "http".
Overrides:
getProtocol in class AdaptorSocket
 o doBind
 public void doBind() throws IOException
Binds this adaptor socket to a specified port. The adaptor socket is bound on to receive requests and is usually used on the server side.

Throws: IOException
An I/O error occurred when opening the socket.
Overrides:
doBind in class AdaptorSocket
 o doUnbind
 public void doUnbind() throws IOException
Unbinds this adaptor socket. Used on the client and server sides.

Throws: IOException
An I/O error occurred when opening the socket.
Overrides:
doUnbind in class AdaptorSocket
 o doConnect
 public void doConnect(String serverName,
                       int serverPort) throws UnknownHostException, IOException, CommunicationException
Connects this adaptor socket to a specified server and port. The adaptor socket is connected to send a request and is usually used on the client side.

Parameters:
serverName - The name of the server to connect the socket to.
serverPort - The port number on the specified server.
Throws: UnknownHostException
The IP address of the specified server could not be determined.
Throws: IOException
An I/O error occurred when opening the socket.
Throws: CommunicationException
A communications problem occurred.
Overrides:
doConnect in class AdaptorSocket
 o doDisconnect
 public void doDisconnect() throws IOException, CommunicationException
Disconnects this adaptor socket. Used on the client and server sides. On the client side, disconnects the adaptor socket used for the connection. On the server side, disconnects the adaptor socket involved in communication with the client, this is not usually the socket used for binding.

Throws: IOException
An I/O error occurred when disconnecting the socket.
Throws: CommunicationException
A communications problem occurred.
Overrides:
doDisconnect in class AdaptorSocket
 o doSend
 public void doSend(String header,
                    byte content[]) throws IOException
Sends the specified header and content to the peer. Used on the client and server sides. On the client side, this is usually the initiating request. On the server side, this is the reply to the client's request.

Parameters:
header - The message header.
content - The message content.
Throws: IOException
An I/O error occurred.
Overrides:
doSend in class AdaptorSocket
 o doReceive
 public InputStream doReceive() throws IOException
Waits for an incoming message. Used on the client and server sides. On the server side, this waits for a request from the client. On the client side, this waits for the reply to the client's request.

Returns:
The input stream from this adaptor socket.
Throws: IOException
An I/O error occurred.
Overrides:
doReceive in class AdaptorSocket
 o doGetInputStream
 public InputStream doGetInputStream() throws IOException
Returns an input stream for this adaptor socket.

Returns:
The input stream from this adaptor socket.
Throws: IOException
An I/O error occurred.
Overrides:
doGetInputStream in class AdaptorSocket
 o getLocalAddress
 public InetAddress getLocalAddress()
Returns the local IP address. Can be used on the client and server sides.

Returns:
The IP address of the local adaptor socket.
Overrides:
getLocalAddress in class AdaptorSocket
 o getLocalPort
 public int getLocalPort()
Returns the local port number. Can be used on the client and server sides.

Returns:
The port number of the local adaptor socket.
Overrides:
getLocalPort in class AdaptorSocket
 o getRemoteAddress
 public InetAddress getRemoteAddress()
Returns the remote IP address. Can be used on the client and server sides.

Returns:
The IP address of the remote adaptor socket.
Overrides:
getRemoteAddress in class AdaptorSocket
 o getRemotePort
 public int getRemotePort()
Returns the remote port number. Can be used on the client and server sides.

Returns:
The port number of the remote adaptor socket.
Overrides:
getRemotePort in class AdaptorSocket
 o toString
 public String toString()
Returns the implementation address and implementation port of this socket as a string.

Returns:
A string containing the implementation address and implementation port of this socket.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index