14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!
The problem is that you close the client socket, both on the client and on the server, and then you try to use that socket again. After the socket has been closed you can't use it to send or receive. You would have to reconnect to the server each time you send or keep the connection open the whole time.