Initial modification to include a separate thread to complete the TCP sending