---
name: "netwrite"
section: "3"
platform: "linux"
package: "liblcgdm-dev"
version: "1.10.0-2+b3"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/netwrite/3"
---

# netwrite(3)

send a message on a socket

## NAME

netwrite - send a message on a socket

## SYNOPSIS

**#include "net.h"**

**int netwrite (int** *s***,** **char \****buf***,** **int** *nbytes***);**

**ssize\_t netwrite\_timeout (int** *s***,** **void \****buf***,** **size\_t** *nbytes***,** **int** *timeout***);**

## DESCRIPTION

**netwrite** sends a message on a socket.

## RETURN VALUE

This routine returns the number of bytes if the operation was successful, 0 if the connection was closed by the remote end or -1 if the operation failed. In the latter case, **serrno** is set appropriately.

## ERRORS

- **EINTR**

  The function was interrupted by a signal.

- **EBADF**

  *s* is not a valid descriptor.

- **EAGAIN**

  The socket is non-blocking and there is no space available in the system buffers for the message.

- **EFAULT**

  *buf* is not a valid pointer.

- **EINVAL**

  *nbytes* is negative or zero.

- **ENOTSOCK**

  *s* is not a socket.

- **SECONNDROP**

  Connection closed by remote end.

- **SETIMEDOUT**

  Timed out.

## SEE ALSO

**[send(2)](/send/2.md)**, **neterror(3)**

## AUTHOR

**LCG Grid Deployment** Team
