change write/read to send/recv on socket operations