public class AsyncJavaSocketTransport extends AbstractAsyncSocketTransport
AsyncSocketTransport
.Modifier and Type | Field and Description |
---|---|
static AsynchronousChannelGroup |
channelGroup
Channel group used by the AsyncSocketChannels.
|
config, connectionStatus, connectionString, host, lastConnectTime, lastUseTime, port, serverIndex, transportFactory
Constructor and Description |
---|
AsyncJavaSocketTransport(String phost,
int pport,
AsyncSocketTransportFactory ptransportFactory)
Creates an AsyncJavaSocketTransport.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the Socket connection.
|
void |
connectInternal(AsyncHandler<Boolean> handler)
Connect Method to be implemented by sub-class.
|
boolean |
flush(AsyncHandler<Integer> handler)
Flushes bytes in buffer to Socket Output.
|
static AsynchronousChannelGroup |
getChannelGroup() |
int |
read(OutputStream dest,
int maxBytes,
AsyncHandler<Integer> handler)
Reads atleast 1 byte and a max of upto maxBytes writing bytes read to specified
Stream.
|
boolean |
requiresFlush()
Whether the Socket Output requires a flush to transfer bytes in buffer.
|
static void |
setChannelGroup(AsynchronousChannelGroup pchannelGroup)
Sets a custom channel group.
|
int |
write(byte[] b,
int ofs,
int len,
AsyncHandler<Integer> handler)
Writes specified bytes to Output Stream.
|
connect, getConfig, getConnectionString, getDownSince, getHost, getPort, getRetryInterval, getServerIndex, getStatus, getTransportFactory, isStale, setConfig, toString, updateConnectionStatus
public static AsynchronousChannelGroup channelGroup
public AsyncJavaSocketTransport(String phost, int pport, AsyncSocketTransportFactory ptransportFactory) throws IOException
phost
- Server Hostpport
- Server PortptransportFactory
- TransportFactory to be associated with this transportIOException
public static AsynchronousChannelGroup getChannelGroup() throws IOException
IOException
public static void setChannelGroup(AsynchronousChannelGroup pchannelGroup)
pchannelGroup
- Channel Group to usepublic void connectInternal(AsyncHandler<Boolean> handler)
AbstractAsyncSocketTransport
connectInternal
in class AbstractAsyncSocketTransport
handler
- handler to call when connection is completedpublic int read(OutputStream dest, int maxBytes, AsyncHandler<Integer> handler)
AsyncSocketTransport
dest
- OutputStream to write bytes ReadmaxBytes
- max Bytes to readhandler
- handler to call in case of Async operationpublic int write(byte[] b, int ofs, int len, AsyncHandler<Integer> handler)
AsyncSocketTransport
b
- Byte Array containing bytes to writeofs
- offset to write fromlen
- number of bytes to writehandler
- handler to call in case of Async operation. The handler is
called after all bytes have been written with the number of bytes actaully
transferred to the Socket Output.public boolean requiresFlush()
AsyncSocketTransport
public boolean flush(AsyncHandler<Integer> handler)
AsyncSocketTransport
handler
- Callback handler in case flush is required. The handler is
called with bytes transferred if further flush call is required or a
negative value of -bytes transferred if further flush call is not required.public void close() throws IOException
AsyncSocketTransport
IOException
Copyright © 2013- Suresh Mahalingam. All Rights Reserved.