Review concurrency
The C code didn't use locks for a lot of accesses on the socket, which seems to be correct, as they only ever occur in one thread. However in Rust, each field that is written to has to be in a Mutex. The Mutex overhead could probably be omitted by using unsafe code to get mutable references without a Mutex.