The low-level format of the addresses are different depending on the mode of communication you have chosen. A function is provided by each of the lower layers to map a user-friendly string-form address to the binary form required by the lower layers.
void *cs_straddr(COMSTACK handle, const char *str);
The format for TCP/IP and SSL addresses is:
<host> [ ':' <portnum> ]
The hostname
can be either a domain name or an
IP address. The port number, if omitted, defaults to 210.
For TCP/IP and SSL, the special hostnames @
,
maps to IN6ADDR_ANY_INIT
with
IPV4 binding as well (bindv6only=0),
The special hostname @4
binds to
INADDR_ANY
(IPV4 only listener).
The special hostname @6
binds to
IN6ADDR_ANY_INIT
with bindv6only=1 (IPV6 only listener).
For UNIX sockets, the format of an address is the socket filename.
When a connection has been established, you can use
const char *cs_addrstr(COMSTACK h);
to retrieve the host name of the peer system. The function returns a pointer to a static area, which is overwritten on the next call to the function.
A fairly recent addition to the COMSTACK module is the utility function
COMSTACK cs_create_host (const char *str, int blocking, void **vp);
which is just a wrapper for cs_create
and
cs_straddr
. The str
is similar to that described for cs_straddr
but with a prefix denoting the COMSTACK type. Prefixes supported
are tcp:
, unix:
and
ssl:
for TCP/IP, UNIX and SSL respectively.
If no prefix is given, then TCP/IP is used.
The blocking
is passed to
function cs_create
. The third parameter
vp
is a pointer to COMSTACK stack type
specific values.
Parameter vp
is reserved for future use.
Set it to NULL
.