External Agent Interface Implementation

External Agent Interface Implementation
SchemeStation documentation

1 Introduction

The external agent interface described in External Agent Interface Specification has some similarities with the networking system (Networking Specification).

The implementation has also some similarities. The server listen to a specified port, accepts connections, and passes the fd's to the event loop. The event loop then wakes a specified function to manage reads and writes from this fd.

The external agent system also inceludes a separate library that the clients may use to connect to the server.

2 Addressing

In the addressing system, there is a special type for external agents. When the messaging system receives a message to be patches and find out from the addressing system, that the destination of the message is an external agent, it passes it to the extarnal agent system instead of the networking system. The addressing system entry contains the fd of the corresponding client connection, so that the mapping in the external agent is rather straightforward.

As said in External Agent Interface Specification, neither the server nor the client is aware of the agent specifiers when in comes to sending a packet to a native agent. Instead, the interface agent dispatches the packets sent by the client, and passes them further to the native agents. (Naturally, it may also decide not pass the packet anywhere.)

3 The server

When a domain is started, the listened port is bound and begun to listen with extag_initialize(). The port number is passed as a command line argument. If listening the port fails, the function returns error.

When the messaging system requests the external agent system to pass a packet to a cient, it specifies the client with the fd of the connection. The external agent system then searches its list of readily established connection if there is one with that fd. If such one is found, it then puts the packet on the connection's list of packets to be send with extag_deliverpacket.

The event loop notifies external agent module every time it is possibly to send to a connection by calling extag_eloop_callback. The external agent module then sends as many packets as possible with extag_sendpacket and gives the control back to the caller.

The event loop also notifies the external agent module of arrived packets by calling extag_eloop_callback. The external agent system reads all available packets from the socket with extag_recvpacket and for every completely received packet it calls the addressing systems callback registered with extag_registerpacketcallback. Packets can be partially received or sent, in which case they are completed when the event loop gives controls back next time.

Opening a connection in the erver side consists of calling extag_acceptconnection that allocates the connection struct, adds it to the global connection list, accepts the socket connection, and does handshake with extag_doclienthandshake.

The parties can use control commands to for example close connection. If the data length is set zero, the packet includes a (network byte order) 2-octet control command a argument. These include opening a connection (0) and closing a connection (1). These command are handled by extag_handlecontrol.

4 The ssextagent library

The ssextagent library implements the interface described in External Agent Interface Specification in a staighteforward manner.

5.9.7 The functions of module External agent interface


File extagent-internal.h

C-functions:


File extagent-packet.h

C-functions:


File extagent.h

C-functions:


File ssextagent.h

C-functions:


File extagent-internal.h

C-functions:


File ssextagent.h

C-functions: