net.named_data.jndn.transport
public class TcpTransport extends Transport
Modifier and Type | Class and Description |
---|---|
static class |
TcpTransport.ConnectionInfo
A TcpTransport.ConnectionInfo extends Transport.ConnectionInfo to hold
the host and port info for the TCP connection.
|
Constructor and Description |
---|
TcpTransport() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the connection.
|
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.
|
static boolean |
getIsLocal(String host)
A static method to determine whether the host is on the current machine.
|
boolean |
isAsync()
Override to return false since connect does not need 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()
Process any data to receive.
|
void |
send(ByteBuffer data)
Send data to the host
|
public boolean isLocal(Transport.ConnectionInfo connectionInfo) throws IOException
isLocal
in class Transport
connectionInfo
- A TcpTransport.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
- A TcpTransport.ConnectionInfo.elementListener
- The ElementListener must remain valid during the
life of this object.onConnected
- If not null, this calls onConnected.run() when the
connection is established.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
public void close() throws IOException
close
in class Transport
IOException
- For I/O error.public static boolean getIsLocal(String host) throws IOException
host
- The host to check.IOException
Copyright © 2016. All rights reserved.