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

# socket\_send4(3)

send a UDP datagram

## NAME

socket\_send4 - send a UDP datagram

## SYNTAX

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

ssize\_t **socket\_send4**(int *s*, const char\* *buf*, size\_t *len*,\
                      const char *ip*\[4\],uint16 *port*);

## DESCRIPTION

socket\_send4 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\_send4 without calling socket\_bind4.  This has the effect as first calling socket\_bind4 with IP address 0.0.0.0 and port 0.

## RETURN VALUE

socket\_send4 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*\[4\];\
   uint16 *p*;

  *s* = socket\_tcp4();\
   socket\_bind4(s,ip,p);\
   socket\_send4(s,"hello, world",12,ip,p);

## SEE ALSO

[socket\_send6(3)](/socket_send6/3.md)
