#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
#include <time.h>
Go to the source code of this file.
Defines | |
#define | NSDS_UTIL_H_ |
read-once define | |
#define | MAX_CMD_LEN 8192 |
Max length of a command on the control channel, see tcp_nl_read. | |
#define | TSTAMP_LEN 32 |
Length, in chars, of ISO 8601 timestamp. | |
#define | DATUM_LEN 32 |
Length, in chars, of a single data point + channel ID. | |
#define | NUM_CHANNELS 128 |
Max number of data channels, only really affects fake_daq. | |
Enumerations | |
enum | socket_wait_ret |
Possible returns on wait-on-socket, simple tristate. More... | |
enum | bool |
Local define of boolean, if not extant. More... | |
Functions | |
int | pthread_setconcurrency (int new_level) |
Hack - prototype pthread_setconcurrency since gcc doesnt have same. | |
int | tcp_socket_make (const uint16_t SRV_PORT, const int QUEUE_LENGTH) |
Create server socket, ready for accept(). | |
int | tcp_nl_write (const int socket, const char *buf) |
Send a string, appending a newline character. | |
int | tcp_nl_read (const uint16_t socket, char *buf, const time_t timeout) |
Read until EOL or MAX_CMD_LEN bytes. | |
int | tcp_connect (const char *server, const uint16_t port) |
Routine, after Comer, for opening a TCP connection. | |
socket_wait_ret | tcp_socket_wait (const int socket, const time_t timeout) |
Function to wait on a socket, with or without timeout. | |
char * | tcp_peername (const int socket) |
Function to return a string w/name of connected peer. | |
int | tcp_connect_retry (const char *host, const uint16_t port, const time_t retry_delay, const time_t end_time, const char *description) |
Loop until can open client connection. | |
void | tcp_close (const int socket_fd) |
Shutdown and close TCP socket. | |
char * | gen_timestamp (void) |
Generate an ISO 8601-compliant timestamp. |
Definition in file nsds_util.h.
|
Length, in chars, of a single data point + channel ID.
Definition at line 57 of file nsds_util.h. Referenced by daq_thread_main(). |
|
Max length of a command on the control channel, see tcp_nl_read.
Definition at line 51 of file nsds_util.h. Referenced by cmd_handler(), daq_do_work(), data_thread_main(), and tcp_nl_read(). |
|
read-once define
Definition at line 14 of file nsds_util.h. |
|
Max number of data channels, only really affects fake_daq.
Definition at line 60 of file nsds_util.h. Referenced by daq_do_work(), daq_thread_main(), data_channel_enabled(), data_channel_flag(), and main(). |
|
Length, in chars, of ISO 8601 timestamp.
Definition at line 54 of file nsds_util.h. Referenced by daq_thread_main(). |
|
Local define of boolean, if not extant.
Definition at line 44 of file nsds_util.h. |
|
Possible returns on wait-on-socket, simple tristate.
Definition at line 34 of file nsds_util.h. Referenced by tcp_nl_read(), and tcp_socket_wait(). |
|
Generate an ISO 8601-compliant timestamp.
Definition at line 46 of file nsds_util.c. Referenced by daq_thread_main(). |
|
Hack - prototype pthread_setconcurrency since gcc doesnt have same.
Referenced by daq_do_work(), and data_thread_startup(). |
|
Shutdown and close TCP socket. Does shutdown (read/write) and then close if fd > 0
Definition at line 620 of file nsds_util.c. Referenced by daq_main_loop(), and main_loop(). |
|
Routine, after Comer, for opening a TCP connection. ---------------------------------------------------------------------
Definition at line 359 of file nsds_util.c. Referenced by tcp_connect_retry(). |
|
Loop until can open client connection.
Definition at line 562 of file nsds_util.c. References tcp_connect(). Referenced by main_loop(). |
|
Read until EOL or MAX_CMD_LEN bytes. --------------------------------------------------------------------- Read from TCP into static buffer until
Yeah, yeah, I know already. Needs dynamic buffers, or sizing, or code that Sucks Less.
Definition at line 246 of file nsds_util.c. References MAX_CMD_LEN, socket_wait_ret, and tcp_socket_wait(). Referenced by cmd_handler(), and daq_do_work(). |
|
Send a string, appending a newline character. ---------------------------------------------------------------------
Definition at line 194 of file nsds_util.c. Referenced by cmd_handler(), daq_do_work(), daq_thread_main(), and tcp_send_driverids(). |
|
Function to return a string w/name of connected peer.
Definition at line 510 of file nsds_util.c. Referenced by daq_main_loop(), and main_loop(). |
|
Create server socket, ready for accept(). ---------------------------------------------------------------------
Definition at line 100 of file nsds_util.c. References QUEUE_LENGTH, and SRV_PORT. Referenced by daq_main_loop(). |
|
Function to wait on a socket, with or without timeout. Blocking or non-blocking wait until a socket is ready for reading. Used in functions that cannot wait forever, as well as ones that can.
Definition at line 437 of file nsds_util.c. References socket_wait_ret. Referenced by tcp_nl_read(). |