public class SocketConnectionFacadeImpl extends Object implements SocketConnectionFacade
| Modifier and Type | Field and Description |
|---|---|
static Pattern |
CRNL_PATTERN |
static int |
MAX_SOCKET_READ_TIMEOUT_MILLIS
3 hrs = 3 * 3660 * 1000
|
static Pattern |
NL_PATTERN |
| Constructor and Description |
|---|
SocketConnectionFacadeImpl(String host,
int port,
boolean ssl,
int timeout,
int readTimeout)
<<<<<<< HEAD Creates a new instance for use with the Manager API that
uses UTF-8 as encoding and CRNL ("\r\n") as line delimiter.
|
SocketConnectionFacadeImpl(String host,
int port,
boolean ssl,
int timeout,
int readTimeout,
Charset encoding)
Creates a new instance for use with the Manager API that uses the given
encoding and CRNL ("\r\n") as line delimiter.
|
SocketConnectionFacadeImpl(String host,
int port,
boolean ssl,
int timeout,
int readTimeout,
Charset encoding,
Pattern lineDelimiter)
Creates a new instance for use with the Manager API that uses the given
encoding and line delimiter.
|
SocketConnectionFacadeImpl(String host,
int port,
boolean ssl,
int timeout,
int readTimeout,
Pattern lineDelimiter)
Creates a new instance for use with the Manager API that uses UTF-8 as
encoding and the given line delimiter.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
InetAddress |
getLocalAddress()
Returns the local address this socket connection.
|
int |
getLocalPort()
Returns the local port of this socket connection.
|
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.
|
String |
readLine()
Reads a line of text from the socket connection.
|
void |
write(String s)
Sends a given String to the socket connection.
|
public static final Pattern CRNL_PATTERN
public static final Pattern NL_PATTERN
public static final int MAX_SOCKET_READ_TIMEOUT_MILLIS
public SocketConnectionFacadeImpl(String host, int port, boolean ssl, int timeout, int readTimeout) throws 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)IOException - if the connection cannot be established.public SocketConnectionFacadeImpl(String host, int port, boolean ssl, int timeout, int readTimeout, Charset encoding) throws 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)encoding - the encoding used for transmission of strings (all
connections should use the same encoding)IOException - if the connection cannot be established.public SocketConnectionFacadeImpl(String host, int port, boolean ssl, int timeout, int readTimeout, Pattern lineDelimiter) throws 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)lineDelimiter - a Pattern for matching the line delimiter
for the socketIOException - if the connection cannot be established.public SocketConnectionFacadeImpl(String host, int port, boolean ssl, int timeout, int readTimeout, Charset encoding, Pattern lineDelimiter) throws 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)encoding - the encoding used for transmission of strings (all
connections should use the same encoding)lineDelimiter - a Pattern for matching the line delimiter
for the socketIOException - if the connection cannot be established.public String readLine() throws IOException
SocketConnectionFacadeDepending on the implementation different newline delimiters are used ("\r\n" for the Manager API and "\n" for AGI).
readLine in interface SocketConnectionFacadeIOException - if the connection has been closed.public void write(String s) throws IOException
SocketConnectionFacadewrite in interface SocketConnectionFacades - the String to send.IOException - if the String cannot be sent, maybe because the
connection has already been closed.public void flush()
throws IOException
SocketConnectionFacadeflush in interface SocketConnectionFacadeIOException - if the connection cannot be flushed.public void close()
throws IOException
SocketConnectionFacadeWhen calling close() any Thread currently blocked by a call to readLine() will be unblocked and receive an IOException.
close in interface SocketConnectionFacadeIOException - if the socket connection cannot be closed.public boolean isConnected()
SocketConnectionFacadeisConnected in interface SocketConnectionFacadetrue if the socket successfuly connected to a
serverpublic InetAddress getLocalAddress()
SocketConnectionFacadegetLocalAddress in interface SocketConnectionFacadepublic int getLocalPort()
SocketConnectionFacadegetLocalPort in interface SocketConnectionFacadepublic InetAddress getRemoteAddress()
SocketConnectionFacadegetRemoteAddress in interface SocketConnectionFacadepublic int getRemotePort()
SocketConnectionFacadegetRemotePort in interface SocketConnectionFacadeCopyright © 2004–2022. All rights reserved.