Once there is a connection, there is no longer any difference between the client and the server. Whatever you do with the client socket can also be done with the server socket.
BTW, you don't need to immediately close the connection. This was just an example.