E
Erakis
Hi
My CF application have to be connected to a TCP server on a PC.
Here is the way I do on client :
The first time the PPC connect to the server all is well working
But If I shut down the Pocket PC using the power button on the device, and
exception occured in the ReceivedThread method. The exception is "A blocking
operation was interrupted by a call to WSACancelBlockingCall".
In this case, a Dispose the Socket and try to reconnect using the Connect
method. The Socket.Connect succed but each time this line is executed :
I got the following exception "An existing connection was forcibly closed by
the remote host". Why ??? I'm unable to reconnect the Pocket PC to the server
!
Two days trying to figuring the problem but I now I don't know what to do
Please help me.
My CF application have to be connected to a TCP server on a PC.
Here is the way I do on client :
Code:
private void Connect(string ip, int portNumber)
clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
clientSocket.Connect(new IPEndPoint(ip, portNumber));
receivedThread = new Thread(new ThreadStart(ReceiveThread));
private void ReceiveThread()
{
byte[] buffer = new byte[512];
int iBytesCount = 0;
while (!stopThread)
{
try
{
iBytesCount = this.clientSocket.Receive(buffer, 0,
this.receiveBufferSize, SocketFlags.None); ;
if (iBytesCount == 0)
break;
}
catch (Exception ex)
{
if (!stopThread)
{
throw new CommunicationException("An exception occured
in received thread.", ex);
}
break;
}
...
}
The first time the PPC connect to the server all is well working
But If I shut down the Pocket PC using the power button on the device, and
exception occured in the ReceivedThread method. The exception is "A blocking
operation was interrupted by a call to WSACancelBlockingCall".
In this case, a Dispose the Socket and try to reconnect using the Connect
method. The Socket.Connect succed but each time this line is executed :
Code:
iBytesCount = this.clientSocket.Receive(buffer, 0, this.receiveBufferSize,
SocketFlags.None); ;
I got the following exception "An existing connection was forcibly closed by
the remote host". Why ??? I'm unable to reconnect the Pocket PC to the server
!
Two days trying to figuring the problem but I now I don't know what to do
Please help me.