conn_server(3)

NAME
conn_server() - connect to a server by name and port

SYNOPSIS
#include "fwfunc.h"

int conn_server(char *srv,int portnum,int priv,char *rbuf)

DESCRIPTION
The conn_server function creates a socket, connected to tcp server srv's port portnum, using highest available privileged source port if priv is non-zero, and any one as regular tcp connection does if it is zero.

If a host has multiple IPs in dns recored, each is tried until some succeeds or list is exhausted.

RETURN VALUES
the function returns socket number on success or a negative value if something fails (-1 if server name does not resolve or invalid, -2 if socket failed to create and -3 if connect failed). A failure reason is written into string pointed by rbuf, if it is specified.

SECURITY CONDITIONS
address entry returned by name lookup exceeds sizeof appropriate structure, action: 'invalid host address length' securityalert is generated, -1 returned.

SEE ALSO
rresvport(3),connect(2)

HISTORY
The function appears in fwtk since v1.0