Classes | |
| struct | daq_listen_t |
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. | |
| int | daq_shutdown (daq_listen_t *lstn) |
| Kill the listener thread. | |
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*) {
}
| 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'.
| lstn | Listener parameter/status structure. | |
| daq | Client structure. | |
| tcp_port | is set to the actual port used. Port number can be increased to allow more than one program copy on the same system. | |
| start_func | Pointer to the funtion to be executed asynchronously when a connection is accepted by the listener. |
| 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.
| lstn | Pointer to listener status structure. |
1.4.7