Should work. (I tried on win32, but don't think that matters in this case)
The steps to test are:
Open a dos window (shell), run your server, your script says "waiting for connections...."
Open a second dos window, run my client. In the window running your server, your script says, "client connected", and also print out 1234, which is sent from my client
Now in the window running your server, type "a msg from server", hit ENTER
In the window running my client, you should see "a msg from server". Also in the window running your server, you should see another 1234, which is again sent from my client.