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 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);
}
|