nds2-client - ClientAdministrator  0.16.8
 All Functions Typedefs Enumerations Enumerator Groups Pages
Functions
Multi-threaded listener

Functions

daq_listen_t * daq_initialize (daq_listen_t *lstn, daq_t *daq, int *tcp_port, void *(*start_func)(void *))
 Create a network listener thread. More...
 
int daq_shutdown (daq_listen_t *lstn)
 Kill the listener thread. More...
 

Detailed Description

The daq2_listen module contains the code to spawn a listener thread that can be used to receive data from the original NDS server. It was originally part of the Daqc API and shared the control structures. A listener is useful in cases where one or more streams of (usually online) data are sent to a port other than the control port to be processed by an asynchronous thread. Note that no alternate port capability is currently planned for NDS2 and that firewalls would interfere with any such activity crossing network borders. The listener code depends on Posix threads (pthreads) and is not available on VxWorks platforms.

A typical use of the NDS listener is as follows:

-- Start a listener thread.
--
daq_t cmd;
int rc;
rc = daq_connect(&cmd, server_ip, server_port, 1);
daq_listen_t lstnr;
daq_initialize(&lstnr, &cmd, data_port, start_func);
...
daq_shutdown(&lstnr);
-- Data reception function.
--
void* start_funct(void*) {
}
Author
John Zweizig (based on code by A. Ivanov)
Version
1.0; last modified March 27, 2008

Function Documentation

daq_listen_t* daq_initialize ( daq_listen_t *  lstn,
daq_t *  daq,
int *  tcp_port,
void *(*)(void *)  start_func 
)

Create a network listener thread.

Create network listener on `*tcp_port' that listens for DAQD server connections and spawns `start_func' as POSIX threads passing `daq' as the argument when connection is established. A `daq_t' structure is allocated and initialized if a NULL pointer is passed as `daq'.

Remarks
Not implemented on VXWORKS.
Parameters
lstnListener parameter/status structure.
daqClient structure.
tcp_portis set to the actual port used. Port number can be increased to allow more than one program copy on the same system.
start_funcPointer to the funtion to be executed asynchronously when a connection is accepted by the listener.
Returns
Pointer to the initialized daq_t structure or 0 if failed.
int daq_shutdown ( daq_listen_t *  lstn)

Kill the listener thread.

Kill listener thread by setting the "shutting_down" flag and then connection to the listener address. This relies on the fact that the interpreter thread (with which listener is synchronized) is finished and listener is blocked on the accept() right now. If this is too much to bother about you could just exit(). Not available on VXWORKS.

Remarks
Not implemented on VXWORKS.
Parameters
lstnPointer to listener status structure.
Returns
DAQD status code.