|
Asterisk-Java | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.asteriskjava.util.internal.SocketConnectionFacadeImpl
public class SocketConnectionFacadeImpl
Default implementation of the SocketConnectionFacade interface using java.io.
Constructor Summary | |
---|---|
SocketConnectionFacadeImpl(java.lang.String host,
int port,
boolean ssl,
int timeout,
int readTimeout)
Creates a new instance for use with the Manager API that uses CRNL ("\r\n") as line delimiter. |
Method Summary | |
---|---|
void |
close()
Closes the socket connection including its input and output stream and frees all associated ressources. |
void |
flush()
Flushes the socket connection by sending 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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SocketConnectionFacadeImpl(java.lang.String host, int port, boolean ssl, int timeout, int readTimeout) throws java.io.IOException
host
- the foreign host to connect to.port
- the foreign port to connect to.ssl
- true
to use SSL, false
otherwise.timeout
- 0 incidcates defaultreadTimeout
- see Socket.setSoTimeout(int)
java.io.IOException
- if the connection cannot be established.Method Detail |
---|
public java.lang.String readLine() throws java.io.IOException
SocketConnectionFacade
Depending on the implementation different newline delimiters are used ("\r\n" for the Manager API and "\n" for AGI).
readLine
in interface SocketConnectionFacade
java.io.IOException
- if the connection has been closed.public void write(java.lang.String s) throws java.io.IOException
SocketConnectionFacade
write
in interface SocketConnectionFacade
s
- the String to send.
java.io.IOException
- if the String cannot be sent, maybe because the
connection has already been closed.public void flush() throws java.io.IOException
SocketConnectionFacade
flush
in interface SocketConnectionFacade
java.io.IOException
- if the connection cannot be flushed.public void close() throws java.io.IOException
SocketConnectionFacade
When calling close() any Thread currently blocked by a call to readLine() will be unblocked and receive an IOException.
close
in interface SocketConnectionFacade
java.io.IOException
- if the socket connection cannot be closed.public boolean isConnected()
SocketConnectionFacade
isConnected
in interface SocketConnectionFacade
true
if the socket successfuly connected to a
serverpublic java.net.InetAddress getLocalAddress()
SocketConnectionFacade
getLocalAddress
in interface SocketConnectionFacade
public int getLocalPort()
SocketConnectionFacade
getLocalPort
in interface SocketConnectionFacade
public java.net.InetAddress getRemoteAddress()
SocketConnectionFacade
getRemoteAddress
in interface SocketConnectionFacade
public int getRemotePort()
SocketConnectionFacade
getRemotePort
in interface SocketConnectionFacade
|
Asterisk-Java | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |