Macaw OS C reference

Function net_read

#include <macaw.h>
int net_read(int s, void *buf, int n);

Takes exactly n bytes from a connection, once that many have arrived. Use it when you know how much is coming.

Parameters

sint
The connection's number.
bufvoid *
Where the bytes go. It has to hold at least n bytes.
nint
How many bytes to take.

Returns int

n, or -1 if fewer than n bytes have arrived so far (and then it takes none).

In The network, with net_online, net_dial, net_connect, net_send, net_readline, net_receive, net_status, net_peer, net_close, net_listen, net_accept, net_port.