1socket_fastopen_connect4(3)Library Functions Manualsocket_fastopen_connect4(3)
2
3
4

NAME

6       socket_fastopen_connect4 - make a TCP connection and send some data
7

SYNTAX

9       #include <socket.h>
10
11       ssize_t socket_fastopen_connect4(int s,const char ip[4],uint16 port,
12                                        const char* buf,size_t len);
13

DESCRIPTION

15       socket_fastopen_connect4  attempts to make a connection from TCP socket
16       s to TCP port port on IP address ip.  If that succeeds, it attempts  to
17       send len bytes from buf.
18
19       The difference to calling socket_connect4 followed by write is that, on
20       platforms supporting TCP Fast Open, socket_fastopen_connect4 will  send
21       the  first data packet in the third packet of the TCP handshake, saving
22       one useless ACK packet in network traffic.
23
24       This is only useful for protocols where  the  client  sends  the  first
25       bytes.
26
27       socket_connect4 may return
28
29
30       ·      >=0,  to  indicate  that  the connection succeeded and this many
31              bytes were sent.
32
33       ·      -1, setting errno to error_inprogress  or  error_wouldblock,  to
34              indicate that the socket is non-blocking
35
36       ·      -1,  setting  errno to something else, to indicate that the con‐
37              nection failed (and failed immediately, if the  socket  is  non-
38              blocking).
39
40       When a background connection succeeds or fails, s becomes writable; you
41       can use socket_connected to see whether the connection  succeeded.   If
42       the connection failed, socket_connected returns 0, setting errno appro‐
43       priately.
44
45       Once a TCP socket is connected, you can use the read and  write  system
46       calls to transmit data.
47
48       You  can  call  socket_connect4 without calling socket_bind4.  This has
49       the effect as first calling socket_bind4 with IP  address  0.0.0.0  and
50       port 0.
51
52

EXAMPLE

54         #include <socket.h>
55
56         int s;
57         char ip[4];
58         uint16 p;
59
60         s = socket_tcp4();
61         socket_bind4(s,ip,p);
62         socket_fastopen_connect4(s,ip,p,"hello",5);
63
64

SEE ALSO

66       socket_connect4(3), socket_fastopen_connect6(3), socket_fastopen(3)
67
68
69
70                                                   socket_fastopen_connect4(3)
Impressum