I've finally finished my TCP server and it's all working fine on my personal machine (which I used to write and test the program) which is Windows 7.

However, when transferring the program to my VPS (which is Windows XP) the program gives the following exception when attempting to receive data for about 49/50 attempts to connect by the client (randomly works every now and again):

Exception thrown on 9/22/2010 4:04:36 PM: System.Net.Sockets.SocketException (0x80004005): The I/O operation has been aborted because of either a thread exit or an application request
   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
   at AnonMTS.Server.ClientConnection.Receive(IAsyncResult result)

This simply happens when EndReceive is called (BeginReceieve and such are correctly called before and it all works on my first machine), and I just simply don't understand why.

Both machines have the .NET framework 4.0 and the .NET MySQL connector which are as far as I know the only files needed for the program to run...

From MSDN documentation on the Socket class:

If you receive a SocketException, use the SocketException.ErrorCode property to obtain the specific error code. After you have obtained this code, refer to the Windows Sockets version 2 API error code documentation in the MSDN library for a detailed description of the error.


Stupid question really, sorry.

The error code was 995 which I fixed by adding a WaitOne() call to the result gotten from the BeginReceive function =)