SYNTAX

       #include "socket_if.h"

       int socket_connect4(int s,const char ip[4],uint16 port);
       int socket_connect6(int s,const char ip[16],uint16 port,
                           uint32 scope_id);
       int socket_connect(int s,const char ip[16],uint16 port,
                          uint32 scope_id);

       int socket_connected(int s);


DESCRIPTION

       socket_connect4 attempts to make a connection from TCP or UDP socket s
       to TCP port port on IP address ip.  You can call socket_connect4
       without calling socket_bind4.  This has the effect as first calling
       socket_bind4 with IP address 0.0.0.0 and port 0.

       socket_connect6 attempts to make a connection from TCP or UDP socket s
       to TCP port port on IP address ip and scope_id.  The meaning of
       scope_id is dependent on the implementation and IPv6 IP.  For link-
       local IPv6 addresses it specifies the outgoing interface index.  From a
       given interface name (e.g. "eth0") it's index can be retrieved with
       socket_getifidx.  scope_id should normally be set to 0.  You can call
       socket_connect6 without calling socket_bind6.  This has the effect as
       first calling socket_bind6 with IP address :: and port 0.

       socket_connect attempts to make a connection from TCP socket s to TCP
       port port on IP address ip and scope_id calling socket_connect6.  If
       however,  ip is an IPv4 or IPv4-mapped IPv6 address socket_connect4 is
       called instead.

       Once a socket is connected, you can use the read and write system calls
       to transmit data.

       socket_connected can be used to verify, whether a background connection
       failed or succeeded, thus s became writable or not.


EXAMPLE

         #include <socket_if.h>

         int s;
         char localip[16];
         char remoteip[16];
         uint16 p = 0;

         s = socket_tcp();
         socket_bind(s,localip,p,0);
         socket_connect(s,remoteip,p,0);

         if (socket_connected(s) != 1)
           strerr_die2sys(111,fatal,"unable to setup TCP connection: ");

         if (socket_connected(s) != 1)
           strerr_die2sys(111,fatal,"unable to setup TCP connection: ");

RETRURN CODES

       socket_connect4, socket_connect6 and socket_connect may return <0, to
       indicate that the connection succeeded (and succeeded immediately, if
       the socket is non-blocking) -1, setting errno to error_inprogress or
       error_wouldblock, to indicate that the socket is non-blocking -1,
       setting errno to something else, to indicate that the connection failed
       (and failed immediately, if the socket is non-blocking).

       socket_connected returns 1 if s is a socket and a connection is
       established, 0 otherwise and setting errno appropriately.

SEE ALSO

       socket_if(3), socket_info(3), socket_bind(3), socket_recv(3),
       socket_send(3), socket_setup(3), socket_tcp(3), socket_udp(3)



                                       3                qlibs:(socket_connect)

Man(1) output converted with man2html