Transfer file with single threads through sockets