socket_fastopen_connect4 - Man Page

make a TCP connection and send some data


#include <socket.h>

ssize_t socket_fastopen_connect4(int s,const char ip[4],uint16 port,
                                const char* buf,size_t len);


socket_fastopen_connect4 attempts to make a connection from TCP socket s to TCP port port on IP address ip.  If that succeeds, it attempts to send len bytes from buf.

The difference to calling socket_connect4 followed by write is that, on platforms supporting TCP Fast Open, socket_fastopen_connect4 will send the first data packet in the third packet of the TCP handshake, saving one useless ACK packet in network traffic.

This is only useful for protocols where the client sends the first bytes.

socket_connect4 may return

When a background connection succeeds or fails, s becomes writable; you can use socket_connected to see whether the connection succeeded.  If the connection failed, socket_connected returns 0, setting errno appropriately.

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

You can call socket_connect4 without calling socket_bind4.  This has the effect as first calling socket_bind4 with IP address and port 0.


 #include <socket.h>

 int s;
 char ip[4];
 uint16 p;

 s = socket_tcp4();

See Also

socket_connect4(3), socket_fastopen_connect6(3), socket_fastopen(3)

Referenced By

socket_connect4(3), socket_fastopen(3), socket_fastopen_connect6(3).