Socket: 6 Loading on Connection

Up: GEOS SDK TechDocs| Up | Prev: 5 Accepting a Connection | Next: 7 Sending and Receiving Data
SocketAddLoadOnMsg(), SocketAddLoadOnMsgInDomain(), SocketRemoveLoadOnMsg(), SocketRemoveLoadOnMsgInDomain()

It's all very well that you can tell a running program to accept packets and connections over sockets. However, it seems unreasonable to ask the user to run these programs by hand any time there might be a pending connection.

You can tell the Socket library to load a particular geode when it receives data on a particular port, or on a particular port via a particular domain. For an example, see the Appl/SDK_C/Talk sample application: if you run Talk and press the Autoload button, the Socket library knows to start up the Talk program because it senses that it is receiving an incoming Talk connection.

When the program starts up, it should probably create a socket, bind it to the appropriate port, and make that socket listen. If the listening socket is then destroyed, then any unaccepted connections are canceled.

The Socket library writes out an entry to the GEOS.INI file in the [socket] category and with key "LoadOnMsg". The Socket library consults these GEOS.INI file entries when it starts up and will act accordingly when it receives packets.

To make the Socket library load a program when receiving packets on a particular port, call SocketAddLoadOnMsg() . Specify the program by means of its path. To load a program when receiving packets on a particular port on a particular domain, call SocketAddLoadOnMsgInDomain() .

To remove the entries from the GEOS.INI file and tell the Socket library not to try to load the program when receiving packets, call either SocketRemoveLoadOnMsg() or SocketRemoveLoadOnMsgInDomain() .

To listen for incoming data in this manner, the Socket library effectively binds a socket to monitor the port. Thus


Up: GEOS SDK TechDocs| Up | Prev: 5 Accepting a Connection | Next: 7 Sending and Receiving Data