This module defines the AsyncSocketTransport class which extends Transport and is a helper base class for AsyncTcpTransport and AsyncUnixTransport to implement common socket communication tasks using Python’s asyncio.
Bases: pyndn.transport.transport.Transport
Create a new AsyncSocketTransport in the unconnected state. This will use the asyncio loop to create the connection and communicate asynchronously.
Parameters: | loop – The event loop, for example from asyncio.get_event_loop(). It is the responsibility of the application to start and stop the loop. |
---|
This module defines the AsyncTcpTransport class which extends AsyncSocketTransport for async communication over TCP using Python’s asyncio. This only uses asyncio for communication. To make this thread-safe, you must dispatch calls to send(), etc. to the asyncio loop using, e.g., call_soon_threadsafe, as is done by ThreadsafeFace. To use this, you do not need to call processEvents.
Bases: pyndn.transport.async_socket_transport.AsyncSocketTransport
Create a new AsyncTcpTransport in the unconnected state. This will use the asyncio loop to create the connection and communicate asynchronously.
Parameters: | loop – The event loop, for example from asyncio.get_event_loop(). It is the responsibility of the application to start and stop the loop. |
---|
Bases: pyndn.transport.transport.ConnectionInfo
Create a new AsyncTcpTransport.ConnectionInfo which extends Transport.ConnectionInfo to hold the host and port info for the TCP connection.
Parameters: |
|
---|
Connect according to the info in connectionInfo, and use elementListener. To be thread-safe, this must be called from a dispatch to the loop which was given to the constructor, as is done by ThreadsafeFace.
Parameters: |
|
---|
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 blocking 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: | connectionInfo (TcpTransport.ConnectionInfo) – A TcpTransport.ConnectionInfo with the host to check. |
---|---|
Returns: | True if the host is local, False if not. |
Rtype bool: |
This module defines the AsyncUnixTransport class which extends AsyncSocketTransport for async communication over a Unix socket using Python’s asyncio. This only uses asyncio for communication. To make this thread-safe, you must dispatch calls to send(), etc. to the asyncio loop using, e.g., call_soon_threadsafe, as is done by ThreadsafeFace. To use this, you do not need to call processEvents.
Bases: pyndn.transport.async_socket_transport.AsyncSocketTransport
Create a new AsyncUnixTransport in the unconnected state. This will use the asyncio loop to create the connection and communicate asynchronously.
Parameters: | loop – The event loop, for example from asyncio.get_event_loop(). It is the responsibility of the application to start and stop the loop. |
---|
Bases: pyndn.transport.transport.ConnectionInfo
Create a new AsyncUnixTransport.ConnectionInfo which extends Transport.ConnectionInfo to hold the socket file path for the Unix socket connection.
Parameters: | filePath (str) – The file path of the Unix socket file. |
---|
Connect according to the info in connectionInfo, and use elementListener. To be thread-safe, this must be called from a dispatch to the loop which was given to the constructor, as is done by ThreadsafeFace.
Parameters: |
|
---|
Determine whether this transport connecting according to connectionInfo is to a node on the current machine. Unix transports are always local.
Parameters: | connectionInfo (UnixTransport.ConnectionInfo) – This is ignored. |
---|---|
Returns: | True because Unix transports are always local. |
Return type: | bool |
This module defines the SocketPoller class which is used by the socket-based Transport classes to poll a socket on various platforms.
This module defines the TcpTransport class which extends Transport for communication over TCP.
Bases: pyndn.transport.transport.Transport
Create a new TcpTransport in the unconnected state.
Bases: pyndn.transport.transport.ConnectionInfo
Create a new TcpTransport.ConnectionInfo which extends Transport.ConnectionInfo to hold the host and port info for the TCP connection.
Parameters: |
|
---|
Connect according to the info in connectionInfo, and use elementListener.
Parameters: |
|
---|
Check if the transport is connected.
Returns: | True if connected. |
---|---|
Return type: | bool |
A static method to determine whether the host is on the current machine. Results are not cached. 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 blocking 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: | host (str) – The host to check. |
---|---|
Returns: | True if the host is local, False if not. |
Rtype bool: |
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 blocking 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: | connectionInfo (TcpTransport.ConnectionInfo) – A TcpTransport.ConnectionInfo with the host to check. |
---|---|
Returns: | True if the host is local, False if not. |
Rtype bool: |
Process any data to receive. For each element received, call elementListener.onReceivedElement. This is non-blocking and will silently time out after a brief period if there is no data to receive. You should repeatedly call this from an event loop. You should normally not call this directly since it is called by Face.processEvents. If you call this from an main event loop, you may want to catch and log/disregard all exceptions.
This module defines the Transport class which is a base class for specific transport classes such as UnixTransport.
Bases: object
Bases: object
A Transport.ConnectionInfo is a base class for connection information used by subclasses of Transport.
Close the connection. This base class implementation does nothing, but your derived class can override.
Connect according to the info in ConnectionInfo, and use elementListener.
Parameters: |
|
---|---|
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Check if the transport is connected.
Returns: | True if connected. |
---|---|
Return type: | bool |
Raises RuntimeError: | |
for unimplemented if the derived class does not override. |
Determine whether this transport connecting according to connectionInfo is to a node on the current machine. This affects the processing of Face.registerPrefix(): if the NFD is local, registration occurs with the ‘/localhost/nfd...’ prefix; if non-local, the library will attempt to use remote prefix registration using ‘/localhop/nfd...’
Parameters: | connectionInfo (A subclass of ConnectionInfo) – A ConnectionInfo with the host to check. |
---|---|
Returns: | True if the host is local, False if not. |
Rtype bool: |
Process any data to receive. For each element received, call elementListener.onReceivedElement. This is non-blocking and will silently time out after a brief period if there is no data to receive. You should repeatedly call this from an event loop. You should normally not call this directly since it is called by Face.processEvents. If you call this from an main event loop, you may want to catch and log/disregard all exceptions.
Raises RuntimeError: | |
---|---|
for unimplemented if the derived class does not override. |
This module defines the UdpTransport class which extends Transport for communication over UDP.
Bases: pyndn.transport.transport.Transport
Create a new UdpTransport in the unconnected state.
Bases: pyndn.transport.transport.ConnectionInfo
Create a new UdpTransport.ConnectionInfo which extends Transport.ConnectionInfo to hold the host and port info for the UDP connection.
Parameters: |
|
---|
Connect according to the info in connectionInfo, and use elementListener.
Parameters: |
|
---|
For UDP, there really is no connection, but just return True if connect has been called.
Returns: | True if connected. |
---|---|
Return type: | bool |
Determine whether this transport connecting according to connectionInfo is to a node on the current machine. UDP transports are always non-local.
Parameters: | connectionInfo (UdpTransport.ConnectionInfo) – This is ignored. |
---|---|
Returns: | False because UDP transports are always non-local. |
Return type: | bool |
Process any data to receive. For each element received, call elementListener.onReceivedElement. This is non-blocking and will silently time out after a brief period if there is no data to receive. You should repeatedly call this from an event loop. You should normally not call this directly since it is called by Face.processEvents. If you call this from an main event loop, you may want to catch and log/disregard all exceptions.
This module defines the UnixTransport class which extends Transport for communication over a Unix socket.
Bases: pyndn.transport.transport.Transport
Create a new UnixTransport in the unconnected state.
Bases: pyndn.transport.transport.ConnectionInfo
Create a new UnixTransport.ConnectionInfo which extends Transport.ConnectionInfo to hold the socket file path for the Unix socket connection.
Parameters: | filePath (str) – The file path of the Unix socket file. |
---|
Connect according to the info in connectionInfo, and use elementListener.
Parameters: |
|
---|
Check if the transport is connected.
Returns: | True if connected. |
---|---|
Return type: | bool |
Determine whether this transport connecting according to connectionInfo is to a node on the current machine. Unix transports are always local.
Parameters: | connectionInfo (UnixTransport.ConnectionInfo) – This is ignored. |
---|---|
Returns: | True because Unix transports are always local. |
Return type: | bool |
Process any data to receive. For each element received, call elementListener.onReceivedElement. This is non-blocking and will silently time out after a brief period if there is no data to receive. You should repeatedly call this from an event loop. You should normally not call this directly since it is called by Face.processEvents. If you call this from an main event loop, you may want to catch and log/disregard all exceptions.