Macaw OS C reference

Function net_readline

#include <macaw.h>
int net_readline(int s, char *buf, int size);

Takes one whole line that has arrived on a connection. Use it for text that comes a line at a time, like a chat or a web server's answer.

Parameters

sint
The connection's number.
bufchar *
Where the line goes, without its line ending (\n or \r\n).
sizeint
How many bytes buf holds. The rest of a line that doesn't fit is lost.

Returns int

The line's whole length, or -1 if no whole line has arrived yet. Once the other end closes, a last line without an ending comes too.

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