summaryrefslogtreecommitdiffstats
path: root/src/civetweb/docs/api/mg_read.md
blob: c7ec6c3df24d28fe45d862a0606f96369b41a2f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Civetweb API Reference

### `mg_read( conn, buf, len );`

### Parameters

| Parameter | Type | Description |
| :--- | :--- | :--- |
|**`conn`**|`struct mg_connection *`| A pointer referencing the connection |
|**`buf`**|`void *`| A pointer to the location where the received data can be stored |
|**`len`**|`size_t`| The maximum number of bytes to be stored in the buffer |

### Return Value

| Type | Description |
| :--- | :--- |
|`int`| The number of read bytes, or a status indication |

### Description

The function `mg_read()` receives data over an existing connection. The data is handled as binary and is stored in a buffer whose address has been provided as a parameter. The function returns the number of read bytes when successful, the value **0** when the connection has been closed by peer and a negative value when no more data could be read from the connection.

### See Also

* [`mg_printf();`](mg_printf.md)
* [`mg_write();`](mg_write.md)