run() returns, the socket goes out of scope, the thread terminates. All that before anything is actually written to the socket. You must have some kind of loop in run() to keep it going.