HTTP and TCP
wackasm_opencomputers::internet uses the first internet card (or one you
choose) for HTTP(S) and TCP. Response and TcpStream are ordinary
std::io streams.
send() waits for the status line and headers. Every status, 404 included,
is a Response; errors are for requests that fail (unknown host, refused,
blocked by the server’s config). Response::header(name) looks one up
case-insensitively.
try_read reads what has arrived without waiting for more: Ok(None) if
nothing has, Ok(Some(0)) once the other side has closed.
Things to know
Section titled “Things to know”- Reads come in chunks of at most 2 KiB, one per server tick: about 40 KB/s. Waiting for data costs a tick per check, not fuel.
- The server’s OpenComputers config decides what’s reachable. By default local and private addresses are blocked.
- Dropping a
ResponseorTcpStreamcloses the connection and frees it on the server.std::process::exitskips destructors, so drop connections before exiting, or they stay open until the computer stops.