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.
-
AdaptorSocket()
- Default constructor.
-
AdaptorSocket(int)
- Constructor.
-
createClientSocket()
- Creates a client socket.
-
createServerSocket(int)
- Creates a server socket using the specified port.
-
doBind()
- Binds this adaptor socket to a specified port.
-
doConnect(String, int)
- Connects this adaptor socket to a specified server and port.
-
doDisconnect()
- Disconnects this adaptor socket.
-
doGetInputStream()
- Returns an input stream for this adaptor socket.
-
doReceive()
- Waits for an incoming message.
-
doSend(String, byte[])
- Sends the specified header and content to the peer.
-
doUnbind()
- Unbinds this adaptor socket.
-
getLocalAddress()
- Returns the local IP address.
-
getLocalPort()
- Returns the local port number.
-
getProtocol()
- Returns the name of the protocol used.
-
getRemoteAddress()
- Returns the remote IP address.
-
getRemotePort()
- Returns the remote port number.
-
toString()
- Returns the implementation address and implementation port of this socket as a string.
AdaptorSocket
public AdaptorSocket()
- Default constructor. Creates an instance of an HTTP/TCP adaptor socket.
AdaptorSocket
public AdaptorSocket(int port)
- Constructor. Creates an instance of an HTTP/TCP adaptor socket using a specified port.
- Parameters:
- port - The port number.
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
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
getProtocol
public String getProtocol()
- Returns the name of the protocol used.
- Returns:
- The string "http".
- Overrides:
- getProtocol in class AdaptorSocket
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
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
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
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
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
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
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
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
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
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
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
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