Made message sending thread-safe (hopefully) by moving the task to the correct thread (thread owning the socket).