AIDA Peer To Peer Net Component

The P2PNet component formally is a hardware driver component. It can be used to transfer data between applications through an AIDA stack. The P2PNet component can operate either in server mode where it waits for incoming connections or in client mode where it actively tries to establish a connection to the configured peer or it can be set to a passive mode without any activities which is the default after loading. Since only one server at a time is allowed for a given port the passive mode is necessary to avoid errors when loading the component more than once.

When a connection has been established the P2PNet component converts all transmit data events to receive data events and transfers them to the peer. On the other hand all incoming receive data events are passed upwards. All other types of AIDA events are discarded and will not be transferred over the network connection.

Remarks

Client mode

In client mode the P2PNet component cyclically tries to connect to the peer until the connection can be established. So the Peer parameter can already be set before actually the peer (another P2PNet component in server mode) is available. When the connection breaks the component automatically tries to reconnect to the peer. The AIDA stack will go online as soon as a connection could be established.

Server mode
In server mode the P2PNet component waits for incoming connections. Only one P2PNet component at a time can listen on a given port. In server mode the P2PNet component will accept only one connection at a time. The backlog buffer will then be disabled to avoid other pending incoming connections. The AIDA stack will go online as soon as a connection could be established.

Network port

Every network connection is defined by a socket pair where each one contains an ip address and a port number (and some more information that is of no further interest here). The port number configurable by the parameter Port (see below) selects the network port the P2PNet component tries to connect to in client mode or listens on in server mode. When the default port is selected the component first tries to get the port number to be used from the services file. The service it requests for is named "bsk_p2pnet". When the service cannot be found the component uses a preconfigured port which is 50007 for P2PNet.

Initial data exchange

After the network connection has been established the P2PNet component exchanges its interface version with the peer. If the received version information does not match the connection will be cancelled.

Timer events

Timer events will only be generated as long as a connection is established.

Parameters

Peer
Specifies the operating mode and the peer to connect to. The following values are allowed:
"."   passive mode  The component enters the passive mode where it neither accepts connectios nor tries to establish connections. This is the default after loading.
"" (empty string)   server mode  The component enters the server mode.
<host name>   client mode  The component enters the client mode. The host name may be passed in either dotted notation (e. g. 192.168.1.2, 127.0.0.1, 127.1, 0x7f.1) or as a symbolic name (e. g. localhost, myhost.mysite.com). When the host name cannot be resolved the value is reset to ".".
Port
Specifies the network port to be used. A value of -1 selects the default port.

See Also

AIDA Overview, list of AIDA components