This package provides a means for PLAN programs to interact with host applications. The package makes use of the PLAN type port, which serves to name a duplex connection between an active router and a host application. The active router side of the port always receives PLAN packets, while the application side receives output in a number of formats, depending on the service command used. When a PLAN packet is first injected into the network onto a particular node, it is associated with its injection port on that node. This port is referred to as the implicit port of a packet.
Currently, ports are implemented as TCP/IP connections -- that is, each PLAN port names a TCP/IP connection between some Active Router and a host application.
Ports may be created implicitly or explicitly. Each Active Router has a server socket listening to a particular TCP port number (specified when the router is invoked, see the tutorial document for more) which accepts client connections. When this connection is created, the router tracks it in a table and creates a PLAN port to name the connection. Any packets that arrive via this connection will have this PLAN port as their implicit port. A port may be created explicitly within an executing PLAN program by the routine openPort. This routine attempts to connect to a server application listening on the specified host and TCP port number, and if successful returns the PLAN port associated with the connection.
Ports are only valid on the router which shares the TCP connection that the port names. In other words, if port A lives on router R, but a PLAN program attempts to send data through it while executing on router S, the operation will fail.
Note that PLAN port names are not stored in any explicit way on the routers. Therefore, a PLAN program that wishes to use a port must retain the name of that port. This serves to prevent one PLAN application from using the ports of another. Note that PLAN programs may use the resident data facility to store the names of ports on the routers (see Subsection 6.2.3 for more on resident data).
A TCP connection named by a port is closed whenever a PLAN program explicitly closes it via closePort, or when the peer terminates the connection.
If the specified port was closed previously, or does not reside on this router, the exception InvalidPort will be raised. If delivery fails for any other reason, the exception DeliveryFailed will be raised.