Now I have a strange problem.
1. When I send the first piece of data from client to server I am able to receive a response from the server.
2. Then I try to send the smae piece of data again, but this time ioctlsocket always reports that 0 bytes is available to read from the socket (nLength is always 0).
The strange thing is that if I use wireshark I can see that the server has actually sent data to the client.
What would cause ioctlsocket to report that nLength = 0 whenever I can see data sent via wireshark???
When using sockets you are never guarenteed that the number of bytes you send or receive will be sent all at once. You must put your sends and receives in a loop! This is because even though the IP layer tries to negotiate to use the same number of bytes on each side, they aren't always able to do so.
So, I would change the name of your variable from "err" to "bytesReceived" or something like that.