socket_connect6(3) - Linux man page

Name

socket_connect6 - attempt to make a TCP connection

Syntax

#include <socket.h>

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

Description

socket_connect6 attempts to make a connection from TCP socket s to TCP port port on IP address ip.

The meaning of scope_id is dependent on the implementation and IPv6 IP. On link-local IPv6 addresses it specifies the outgoing interface index. The name (e.g. "eth0") for a given interface index can be queried with getifname. scope_id should normally be set to 0.

socket_connect6 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_connect6 without calling socket_bind6. This has the effect as first calling socket_bind6 with IP address :: and port 0.

Example

#include <socket.h>

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

s = socket_tcp6();
socket_bind6(s,ip,p);
socket_connect6(s,ip,p,0);

See Also

socket_connect4(3), socket_getifname(3)

Referenced By

socket_getifidx(3), socket_listen(3)