cleanup, docs
This commit is contained in:
@@ -16,4 +16,8 @@ Reads data from a socket connection.
|
||||
`max_length` limits how much data is read, and `timeout` controls how long the operation is allowed to wait.
|
||||
|
||||
:example
|
||||
print("socket_read is resource-bound; configure the service or connection, then call it in request code.\n");
|
||||
u64 fd = socket_connect("127.0.0.1", 80);
|
||||
socket_write(fd, "GET / HTTP/1.0\r\nHost: localhost\r\nConnection: close\r\n\r\n");
|
||||
String chunk = socket_read(fd, 1024, 2);
|
||||
socket_close(fd);
|
||||
print(str_starts_with(chunk, "HTTP/") ? "read an HTTP response from the server" : "no data", "\n");
|
||||
|
||||
Reference in New Issue
Block a user