write and receive between two hosts with threads