G
Guest
I am trying to connect a simple desktop C# Form app to another simple NetCF
C# Form app running under the Emulator using sockets.
The symptom is that after a few String writes from the desktop to the
Emulator the socket drops out with an error of "Unable to read data from the
transport connection." and an internal error of "A blocking operation was
interrupted by a call to WSACancelBlockingCall".
The desktop code is as follows--
IPAddress localAddr = IPAddress.Parse("192.168.1.101");
listener = new TcpListener(localAddr, 1234);
listener.Start();
socket = listener.AcceptSocket();
stream = new NetworkStream(socket);
writer = new BinaryWriter(stream);
this.Th1b=new Thread(new ThreadStart(this.ThSt1b));
Th1b.Name="Th1b";
Th1b.Start();
//desktop thread function for Th1b as follows, choice of TimeIntervalJ1
from 30ms to 7s does not effect the problem
public void ThSt1b()
{
String Error,Str="ThSt1b";
while(ThreadRun1)
{
try
{writer.Write(Str);
Debug.WriteLine("ThSt1b wrote: "+Str);
}
catch(Exception e)
{
Error=e.Message;
return;
}
Thread.Sleep(TimeIntervalJ1);
}
}
The Emulator side is as follows--
//start a thread to handle messages after the connection is made
IPAddress localAddr = IPAddress.Parse("192.168.1.101");
TcpClient client = new TcpClient();
client.Connect(localAddr, 1234);
Stream stream = client.GetStream();
reader = new BinaryReader(stream);
this.Th1a=new Thread(new ThreadStart(this.ThSt1a));
Th1a.Start();
//thread code
public void ThSt1a()
{
String Str="ThSt1a",Error;
while(this.ThreadRun1)
{
try
{Str=reader.ReadString();
TraceEx.WriteLine("ThSt1a read: "+Str);
}
catch(Exception e)
{Error=e.Message;
TraceEx.WriteLine("ThSt1a error: "+Error);
return;
}
}
}
Any help would be appreciated.
Thanks.
C# Form app running under the Emulator using sockets.
The symptom is that after a few String writes from the desktop to the
Emulator the socket drops out with an error of "Unable to read data from the
transport connection." and an internal error of "A blocking operation was
interrupted by a call to WSACancelBlockingCall".
The desktop code is as follows--
IPAddress localAddr = IPAddress.Parse("192.168.1.101");
listener = new TcpListener(localAddr, 1234);
listener.Start();
socket = listener.AcceptSocket();
stream = new NetworkStream(socket);
writer = new BinaryWriter(stream);
this.Th1b=new Thread(new ThreadStart(this.ThSt1b));
Th1b.Name="Th1b";
Th1b.Start();
//desktop thread function for Th1b as follows, choice of TimeIntervalJ1
from 30ms to 7s does not effect the problem
public void ThSt1b()
{
String Error,Str="ThSt1b";
while(ThreadRun1)
{
try
{writer.Write(Str);
Debug.WriteLine("ThSt1b wrote: "+Str);
}
catch(Exception e)
{
Error=e.Message;
return;
}
Thread.Sleep(TimeIntervalJ1);
}
}
The Emulator side is as follows--
//start a thread to handle messages after the connection is made
IPAddress localAddr = IPAddress.Parse("192.168.1.101");
TcpClient client = new TcpClient();
client.Connect(localAddr, 1234);
Stream stream = client.GetStream();
reader = new BinaryReader(stream);
this.Th1a=new Thread(new ThreadStart(this.ThSt1a));
Th1a.Start();
//thread code
public void ThSt1a()
{
String Str="ThSt1a",Error;
while(this.ThreadRun1)
{
try
{Str=reader.ReadString();
TraceEx.WriteLine("ThSt1a read: "+Str);
}
catch(Exception e)
{Error=e.Message;
TraceEx.WriteLine("ThSt1a error: "+Error);
return;
}
}
}
Any help would be appreciated.
Thanks.