net.named_data.jndn.transport
public class AsyncTcpTransport extends Transport
Modifier and Type | Class and Description |
---|---|
static class |
AsyncTcpTransport.ConnectionInfo
AsyncTcpTransport.ConnectionInfo extends Transport.ConnectionInfo to hold
the host and port info for the TCP connection.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_LOCK_TIMEOUT_MS |
Constructor and Description |
---|
AsyncTcpTransport(ScheduledExecutorService threadPool) |
Modifier and Type | Method and Description |
---|---|
void |
connect(Transport.ConnectionInfo connectionInfo,
ElementListener elementListener,
Runnable onConnected)
Connect according to the info in ConnectionInfo, and use elementListener.
|
boolean |
getIsConnected()
Check if the transport is connected.
|
boolean |
isAsync()
Override to return true since connect needs to use the onConnected callback.
|
boolean |
isLocal(Transport.ConnectionInfo connectionInfo)
Determine whether this transport connecting according to connectionInfo is
to a node on the current machine; results are cached.
|
void |
processEvents()
Do nothing since AsynchronousSocketChannel checks for incoming data.
|
void |
send(ByteBuffer data)
Send data to the host.
|
public static final int DEFAULT_LOCK_TIMEOUT_MS
public AsyncTcpTransport(ScheduledExecutorService threadPool)
public boolean isLocal(Transport.ConnectionInfo connectionInfo) throws IOException
isLocal
in class Transport
connectionInfo
- An AsyncTcpTransport.ConnectionInfo with the host to
check.IOException
public boolean isAsync()
public void connect(Transport.ConnectionInfo connectionInfo, ElementListener elementListener, Runnable onConnected) throws IOException
connect
in class Transport
connectionInfo
- An AsyncTcpTransport.ConnectionInfo.elementListener
- The ElementListener must remain valid during the
life of this object.onConnected
- This calls onConnected.run() when the connection is
established. This is needed since connect is async.IOException
- For I/O error.public void send(ByteBuffer data) throws IOException
send
in class Transport
data
- The buffer of data to send. This reads from position() to
limit(), but does not change the position.IOException
- For I/O error.public void processEvents() throws IOException, EncodingException
processEvents
in class Transport
IOException
- For I/O error.EncodingException
- For invalid encoding.public boolean getIsConnected() throws IOException
getIsConnected
in class Transport
IOException
Copyright © 2016. All rights reserved.