Use send() when writing to sockets, and the return type is ssize_t.