8.11 Multi-threaded Demo

(Page 12 of 12 in this chapter)
Name: threads

Purpose: Demonstrates handling of multiple ports using one thread per port.

Usage: threads [options]

where opts are:

Option

Description

-b n

Specifies the AG board number <n>. Default=0.

-s n:m

Specifies the MVIP stream and timeslot for the first channel. Default = 0:0.

-n nports

The number of ports (and threads) to use. Default = 1.

-p protocol

Specifies the protocol to run. Default = lps0.

-f filename

Voice file to use for answering message. Default = answer.vce. (Encoding is assumed to be ADI_ENCODE_NMS_24.)

Highlights:

adiAnswerCall (via DemoWaitForCall)
adiReleaseCall (via DemoHangUp)
adiStartPlaying (via DemoPlayFile)

Description:

A multi-threaded answering machine using demolib. Each thread opens a port and repeatedly waits for calls on the port. Each time a call is received, it answers, plays the answering message, and hangs up.

Procedure:

Ensure proper configuration, with the desired number of lines connected to loop- start hybrids having the same MVIP stream and successive MVIP timeslots. Execute the demo threads, specifying the MVIP stream, the lowest-numbered MVIP timeslot, and the number of timeslots to use. The demo should continue to answer all of the lines until it is stopped.

Note:

Much of the code in threads is for parsing and documenting the command-line arguments and creating thread under various operating systems. All of the call handling is done in RunDemo.


(Page 12 of 12 in this chapter)

Copyright 1996 Natural MicroSystems, Inc. All Rights Reserved.