Solstice X.25 9.2 Developer's Guide

4.2 Listening for Multiple Incoming Calls

Sample code for a listener that can handle several incoming PAD calls simultaneously is provided in the file /opt/SUNWconn/x25/samples.nli/listen.c. Listeners to handle other types of incoming calls are similar. The steps are:

  1. Define the values you need.

    Specify the maximum number of simultaneous calls you want to allow. Set the maximum number of simultaneous calls depending on the processor power available to you and the number of calls you expect to need to handle.

  2. Open the X.25 device.

    The open_stream() function does this. It requests notification from the kernel when there is incoming data on the stream.

  3. Listen for incoming data.

    The do_listen() function specifies the information used to decide what to do with an incoming call. The example shows two ways of doing this, one simple, the other more complex. In the simple example, the program listens for any call user data beginning with the four BCD digits 1234.

  4. Wait for incoming calls.

    To do this, call the getmsg() function. If an incoming call arrives that matches the criteria that you specified in step 1, the X25 driver will send an N_CI indication. At this point, you could choose to do some more sophisticated checking. The example program includes a function called try_next() that tells the X.25 driver to see if the connect message is destined for another application, and a function called reject_call() that tells the X.25 driver to reject the call.

  5. Accept the incoming call.

    Assuming the call is valid, the accept_call() function is used to accept it. Note that when accepting incoming data, the application must copy the call indication identifier into the connect confirm sent to the kernel.

  6. Handle the incoming call as appropriate.

    The sample code contains an example of a call that is handled by printing a message and closing the device (which closes the connection).

  7. Exit the program when finished.