P_tcp4_connect 3porty 2011-04-14 libporty manual

NAME

P_tcp4_connect

SYNPOSIS

#include <libporty/net/tcp4.h>

int P_tcp4_connect (P_net_socket * sock , const char * rem_hostname , int rem_port , const char * loc_hostname , int loc_port , P_net_nonblock_t non_blocking );

Link with -lporty_net

DESCRIPTION

Establish TCP/IPv4 connection to a remote server. A new, connected socket is returned in sock . Remote server is rem_hostname : rem_port . If local binding of the socket is of no importance, loc_hostname should be NULL and/or loc_port should be 0. The call supports two levels of non-blockingness (specified in non_blocking ): P_net_nonblock_connect and P_net_nonblock_socket (if both are needed, P_net_nonblock_full).

Note: if rem_hostname or loc_hostname are not ip addresses, a blocking DNS lookups will be performed.

RETURN VALUE

Returns 0 on success or an error code from P_net_err n failure.

P_tcp4_connect 3porty 2011-04-14 libporty manual