1socket_connect6(3) Library Functions Manual socket_connect6(3)
2
3
4
6 socket_connect6 - attempt to make a TCP connection
7
9 #include <socket.h>
10
11 int socket_connect6(int s, const char ip[16],
12 uint16 port,uint32 scope_id);
13
15 socket_connect6 attempts to make a connection from TCP socket s to TCP
16 port port on IP address ip.
17
18 The meaning of scope_id is dependent on the implementation and IPv6 IP.
19 On link-local IPv6 addresses it specifies the outgoing interface index.
20 The name (e.g. "eth0") for a given interface index can be queried with
21 getifname. scope_id should normally be set to 0.
22
23 socket_connect6 may return
24
25
26 · 0, to indicate that the connection succeeded (and succeeded
27 immediately, if the socket is non-blocking)
28
29 · -1, setting errno to error_inprogress or error_wouldblock, to
30 indicate that the socket is non-blocking
31
32 · -1, setting errno to something else, to indicate that the con‐
33 nection failed (and failed immediately, if the socket is non-
34 blocking).
35
36 When a background connection succeeds or fails, s becomes writable; you
37 can use socket_connected to see whether the connection succeeded. If
38 the connection failed, socket_connected returns 0, setting errno appro‐
39 priately.
40
41 Once a TCP socket is connected, you can use the read and write system
42 calls to transmit data.
43
44 You can call socket_connect6 without calling socket_bind6. This has
45 the effect as first calling socket_bind6 with IP address :: and port 0.
46
47
49 #include <socket.h>
50
51 int s;
52 char ip[16];
53 uint16 p;
54
55 s = socket_tcp6();
56 socket_bind6(s,ip,p);
57 socket_connect6(s,ip,p,0);
58
59
61 socket_connect4(3), socket_getifname(3)
62
63
64
65 socket_connect6(3)