NodeC  0.1
TCP Connections

Communication over the TCP protocol (reliable streaming). More...

Modules

 Low level TCP Connections
 Low level functions to access TCP.
 

Data Structures

struct  tcp_server_config_t
 TCP Server configuration options. More...
 

Macros

#define tcp_server_config()
 Default TCP server configuration.
 

Typedefs

typedef void() nodec_tcp_connection_fun_t(int id, nodec_bstream_t *client, lh_value arg)
 The server callback when listening on a TCP connection. More...
 

Functions

nodec_bstream_tasync_tcp_connect_at (const struct sockaddr *addr, const char *host)
 Establish a TCP connection. More...
 
nodec_bstream_tasync_tcp_connect_at_host (const char *host, const char *service)
 Establish a TCP connection. More...
 
nodec_bstream_tasync_tcp_connect (const char *host)
 Establish a TCP connection. More...
 
void async_tcp_server_at (const struct sockaddr *addr, tcp_server_config_t *config, nodec_tcp_connection_fun_t *servefun, lh_actionfun *on_exn, lh_value arg)
 Create a TCP server. More...
 

Detailed Description

Communication over the TCP protocol (reliable streaming).


Data Structure Documentation

◆ tcp_server_config_t

struct tcp_server_config_t

TCP Server configuration options.

Data Fields
int backlog maximal pending OS request queue length (default 64).
int max_interleaving maximal number concurrent requests (default 1000).
uint64_t timeout ms between connection requests allowed; 0 = infinite, default 5000.
uint64_t timeout_total total allowed connection time in ms; 0 = infinite, default 0.

Typedef Documentation

◆ nodec_tcp_connection_fun_t

typedef void() nodec_tcp_connection_fun_t(int id, nodec_bstream_t *client, lh_value arg)

The server callback when listening on a TCP connection.

Parameters
idThe identity of the current asynchronous strand.
clientThe connecting client data stream.
argThe lh_value passed from async_tcp_server_at().

Function Documentation

◆ async_tcp_connect()

nodec_bstream_t* async_tcp_connect ( const char *  host)

Establish a TCP connection.

Parameters
hostHost address as a url, like "http://www.bing.com".

◆ async_tcp_connect_at()

nodec_bstream_t* async_tcp_connect_at ( const struct sockaddr *  addr,
const char *  host 
)

Establish a TCP connection.

Parameters
addrConnection address.
hostHost name, only used for error messages and can be NULL.

◆ async_tcp_connect_at_host()

nodec_bstream_t* async_tcp_connect_at_host ( const char *  host,
const char *  service 
)

Establish a TCP connection.

Parameters
hostHost address.
serviceCan be a port ("8080") or service ("https"). Uses "http" when NULL.

◆ async_tcp_server_at()

void async_tcp_server_at ( const struct sockaddr *  addr,
tcp_server_config_t config,
nodec_tcp_connection_fun_t servefun,
lh_actionfun on_exn,
lh_value  arg 
)

Create a TCP server.

Parameters
addrThe socket address to serve.
configThe TCP server configuration, can be NULL in which case tcp_server_config() is used.
servefunThe callback called when a client connects.
on_exnOptional function that is called when an exception happens in servefun.
argOptional argument to pass on to servefun, can be lh_value_null.