new TcpTransport()
A TcpTransport connects to the forwarder using TCP for Node.js.
- Source:
Methods
(static) ConnectionInfo(host, port)
Create a new TcpTransport.ConnectionInfo which extends
Transport.ConnectionInfo to hold the host and port info for the TCP
connection.
Parameters:
Name | Type | Description |
---|---|---|
host |
string | The host for the connection. |
port |
number | (optional) The port number for the connection. If omitted, use 6363. |
- Source:
close()
Close transport
- Source:
connect(connectionInfo, elementListener, onopenCallback, onclosedCallback)
Connect to a TCP socket according to the info in connectionInfo. Listen on
the port to read an entire packet element and call
elementListener.onReceivedElement(element). Note: this connect method
previously took a Face object which is deprecated and renamed as the method
connectByFace.
Parameters:
Name | Type | Description |
---|---|---|
connectionInfo |
TcpTransport.ConnectionInfo | A TcpTransport.ConnectionInfo with the host and port. |
elementListener |
object | The elementListener with function onReceivedElement which must remain valid during the life of this object. |
onopenCallback |
function | Once connected, call onopenCallback(). |
onclosedCallback |
function | (optional) If the connection is closed by the remote host, call onclosedCallback(). If omitted or null, don't call it. |
- Source:
connectByFace()
- Deprecated:
- This is deprecated. You should not call Transport.connect directly, since it is called by Face methods.
- Source:
isLocal(onResult, onError)
Determine whether this transport connecting according to connectionInfo is to
a node on the current machine; results are cached. According to
http://redmine.named-data.net/projects/nfd/wiki/ScopeControl#local-face, TCP
transports with a loopback address are local. If connectionInfo contains a
host name, this will do a DNS lookup; otherwise this will parse the
IP address and examine the first octet to determine if it is a loopback
address (e.g. the first IPv4 octet is 127 or IPv6 is "::1").
Parameters:
Name | Type | Description |
---|---|---|
onResult |
function | On success, this calls onResult(isLocal) where isLocal is true if the host is local, false if not. We use callbacks because this may need to do an asynchronous DNS lookup. |
onError |
function | On failure for DNS lookup or other error, this calls onError(message) where message is an error string. |
- Source:
send(data)
Send data.
Parameters:
Name | Type | Description |
---|---|---|
data |
- Source: