---
name: "io_send"
section: "3"
platform: "linux"
package: "libnessus-dev"
version: "1.0.10-2"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/io_send"
---

# io\_send(3)

replacement for socket fuctions

## NAME

io\_send, io\_recv, io\_shutdown, io\_close - replacement for socket fuctions

## SYNOPSIS

```
#include <peks.h>

int io_send (unsigned fd,
             const char *data, unsigned len, unsigned flags);

int io_recv (unsigned fd,
             char *buffer, unsigned len, unsigned flags);

int io_recv_tmo (unsigned fd, int timeout);

int io_shutdown (unsigned fd, unsigned how);

int io_close (unsigned fd);

int io_recv_timeout;
```

## DESCRIPTION

These functions are replacements for the standard socket functions  [**send**(2)](/send/2.md), [**recv**(2)](/recv/2.md), [**shutdown**(2)](/shutdown/2.md) and  [**close**(2)](/close/2.md) unless a data stream diversion has been installed by the function **io\_push()**.

Instead of passing arguments and return codes to and from the socket functions **send()**, or **recv()** the following internal replacements take place:

for the outgoing data stream

**send (***fd***,***buf***,***len***,***flg***)** ::=

**(\****rdwr\_fn***) (***desc***,***buf***,***len***,***flg***)**

and for the incoming data stream

**recv (***fd***,***buf***,***len***,***flg***)** ::=

**(\****rdwr\_fn***) (***desc***,***buf***,***len***,***flg***)**

where the symbol **desc = desc (fd, how)** is a pointer to the data area also returned by **io\_push()**.

The functions **io\_shutdown()** and **io\_close()** work as **shutdown()** and **close()** with an additional call of **io\_pop()**.

The function **io\_recv\_tmo()** imposes a timeout on the receiver **recv()** of the input data stream associated with the first argument.  So the **io\_recv()** call will be thrown out of a blocking wait for input data.  In that case, the global variable **errno** will be set to the value *EINTR*.  In some cases, this is somewhat misleading as--implementation dependent--the timeout also may occur from a timeout detected after a call for **select()** or for **poll().**

**Passing some positive second argument** *n***, a signal SIGALRM** **will be sent to io\_recv() after** *n* **seconds idle time.** **Passing some negative value, the system waits at most** *-n* **seconds** *before* **data are available, but will not interrupt a pending**  **recv() operation.  Passing a 0 value, the timeout is disabled.**

**Upon return, the function returns the old timer value, or -1 if there** **was no input data associated with the first argument.  As a** **consequence, when receiving a value -1, you can only detect an error** **by asking io\_recv\_tmo() again (provided the first timeout** **arguent was different from -1.)**

**By setting the global variable** *io\_recv\_timeout***, the default** **timeout (as changed with io\_recv\_tmo()) that controls the** **receiver recv() in io\_recv() is set, default is 20** **seconds.**

**It is save calling the functions io\_send(), io\_recv(),** **io\_close(), and io\_shutdown() without having installed a** **data stream diversion using io\_push().**

## SEE ALSO

[**errno**(3)](/errno/3.md),  [**iostream**(3)](/iostream/3.md), [**io\_push**(3)](/io_push/3.md), [**send**(2)](/send/2.md), [**recv**(2)](/recv/2.md),  [**socket**(2)](/socket/2.md), [**shutdown**(2)](/shutdown/2.md), [**close**(2)](/close/2.md), **signal**(5),

## AUTHOR

**The peks package where these** **functions belong to was written by Jordan** **Hrycaj \<jordan@teddy-net.com\>, originally** **to support the nessus** **security scanner.**
