---
name: "socket_send6"
section: "3"
platform: "linux"
package: "libowfat-dev"
version: "0.32-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/socket_send6"
---

# socket\_send6(3)

send a UDP datagram

## NAME

socket\_send6 - send a UDP datagram

## SYNTAX

**#include \<libowfat/socket.h\>**

ssize\_t **socket\_send6**(int *s*, const char\* *buf*, size\_t *len*,\
                      const char *ip*\[16\], uint16 *port*, uint32 *scope\_id*);

## DESCRIPTION

socket\_send6 sends *len* bytes starting at *buf* in a UDP datagram over the socket *s* to UDP port *port* on IP address *ip*.

You can call socket\_send6 without calling socket\_bind6.  This has the effect as first calling socket\_bind6 with IP address :: and port 0.

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.

## RETURN VALUE

socket\_send6 returns 0 if the datagram was sent successfully.  If not, it returns -1 and sets errno appropriately.

## EXAMPLE

  \#include \<libowfat/socket.h\>

  int *s*;\
   char *ip*\[16\];\
   uint16 *p*;\
   uint32 *scope\_id*;

  *s* = socket\_tcp4();\
   socket\_bind6(s,ip,p);\
   socket\_send6(s,"hello, world",12,ip,p,scope\_id);

## SEE ALSO

[socket\_send4(3)](/socket_send4/3.md), [socket\_getifidx(3)](/socket_getifidx/3.md)
