moved write wait to the write function in sockets.go