net.sf.asterisk.io
Interface SocketConnectionFacade

All Known Implementing Classes:
SocketConnectionFacadeImpl

public interface SocketConnectionFacade

The SocketConnectionFacade provides read and write operation for communication over TCP/IP sockets.
It hides the details of the underlying I/O system used for socket communication.

Version:
$Id: SocketConnectionFacade.java,v 1.3 2005/09/27 21:07:26 srt Exp $
Author:
srt

Method Summary
 void close()
          Closes the socket connection including its input and output stream and frees all associated ressources.
When calling close() any Thread currently blocked by a call to readLine() will be unblocked and receive an IOException.
 void flush()
          Flushes the socket connection, that is sends any buffered but yet unsent data.
 java.net.InetAddress getLocalAddress()
          Returns the local address this socket connection.
 int getLocalPort()
          Returns the local port of this socket connection.
 java.net.InetAddress getRemoteAddress()
          Returns the remote address of this socket connection.
 int getRemotePort()
          Returns the remote port of this socket connection.
 boolean isConnected()
          Returns the connection state of the socket.
 java.lang.String readLine()
          Reads a line of text from the socket connection.
 void write(java.lang.String s)
          Sends a given String to the socket connection.
 

Method Detail

readLine

java.lang.String readLine()
                          throws java.io.IOException
Reads a line of text from the socket connection. The current thread is blocked until either the next line is received or an IOException encounters.

Returns:
the line of text received excluding any newline character
Throws:
java.io.IOException - if the connection has been closed.

write

void write(java.lang.String s)
           throws java.io.IOException
Sends a given String to the socket connection.

Parameters:
s - the String to send.
Throws:
java.io.IOException - if the String cannot be sent, maybe because the connection has already been closed.

flush

void flush()
           throws java.io.IOException
Flushes the socket connection, that is sends any buffered but yet unsent data.

Throws:
java.io.IOException - if the connection cannot be flushed.

close

void close()
           throws java.io.IOException
Closes the socket connection including its input and output stream and frees all associated ressources.
When calling close() any Thread currently blocked by a call to readLine() will be unblocked and receive an IOException.

Throws:
java.io.IOException - if the socket connection cannot be closed.

isConnected

boolean isConnected()
Returns the connection state of the socket.

Returns:
true if the socket successfuly connected to a server

getLocalAddress

java.net.InetAddress getLocalAddress()
Returns the local address this socket connection.

Returns:
the local address this socket connection.
Since:
0.2

getLocalPort

int getLocalPort()
Returns the local port of this socket connection.

Returns:
the local port of this socket connection.
Since:
0.2

getRemoteAddress

java.net.InetAddress getRemoteAddress()
Returns the remote address of this socket connection.

Returns:
the remote address of this socket connection.
Since:
0.2

getRemotePort

int getRemotePort()
Returns the remote port of this socket connection.

Returns:
the remote port of this socket connection.
Since:
0.2


Copyright © 2004-2005 Stefan Reuter. All Rights Reserved.