eCosPro® Reference Manual
Prev |  | Next

# netconn_recv()

## Name

netconn_recv() -- Wait for data

## Synopsis

``struct netbuf *netconn_recv`(struct netconn *conn);`

## Description

This function blocks the process while waiting for data to arrive on the connection conn. If the connection has been closed by the remote host, NULL is returned, otherwise a netbuf containing the received data is returned.

## Example

Example 4-1. This example demonstrates usage of the `netconn_recv()` function

In the following code, we assume that a connection has been established before the call to `example_function()`.

    void
    example_function(struct netconn *conn)
    {
        struct netbuf *buf;

        /* receive data until the other host closes the connection */
        while((buf = netconn_recv(conn)) != NULL) {
            do_something(buf);
        }

        /* the connection has now been closed by the other end, so we close our end */
        netconn_close(conn);
    }

Prev | Home | Next
netconn_accept() | Up | netconn_write()