Problems using sockets between desktop and WinCE


G

Guest

We are trying to run a Server App on WinCe and communicate with it (sending
an string back and forth) from another App running on the desktop. We are
using WinCe Emulator.

On this Newsgroup it was suggested that we try sockets. I am trying this
now. Code is below.

When I tried both ends using th localhost ("127.0.0.1") I got this error--
"An unhandled exception of type 'System.Net.Sockets.SocketException'
occurred in system.dll
Additional information: No connection could be made because the target
machine actively refused it"

I then doubleclicked the network icon on the WinCe Emulator, got the Ip of
the WinCe Emulator and tried it. I got this error--
"Additional information: A connection attempt failed because the connected
party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond"

The intented use for WinCe and the NetCf is to have an App running on a PCB
in an analytical instrument we manufacture for chemists. This PCB may have a
screen. The instrument will be connected to a computer in some manner. Either
Rs232, USB or a network connection (i.e., RJ45 connector). I am not sure what
they plan at this point. I am trying to learn how to develop Apps using NetCf
and Vs2003 IDE for both the desktop side and the PCB side (i.e., the
analytical instrument). I am using the WinCe Emulator for the learning
curve. The PCB is not available yet.

I have been reading various articles. I can create in C# App's (Console and
Form based) that run on the Emulator. So far in the articles I have read
there is little discussion of how a desktop App might communicate (both ways)
with a WinCe App. Sockets with it's event like behavior would be fine.

Any suggestions would be appreciated.

--John Olbert
(e-mail address removed)

I used the following code in Console Apps that failed--
On WinCe side (the socket server)--
static void Main(string[] args)
{
//IPAddress localAddr = IPAddress.Parse("127.0.0.1");
IPAddress localAddr = IPAddress.Parse("192.168.131.72"); //this is the Ip
from within WinCe
TcpListener listener = new TcpListener(localAddr, 9999);
Console.WriteLine("Waiting for initial connection");
listener.Start();
Socket socket = listener.AcceptSocket();
Console.WriteLine("Connected");
NetworkStream stream = new NetworkStream(socket);
BinaryReader reader = new BinaryReader(stream);
BinaryWriter writer = new BinaryWriter(stream);
String Str=reader.ReadString();
Console.WriteLine(Str);
writer.Write("Hello from Server");
Console.ReadLine();
}

On the desktop side--
static void Main(string[] args)
{
IPAddress localAddr = IPAddress.Parse("192.168.131.72");
TcpClient client = new TcpClient();
//client.Connect("localhost", 9999);
client.Connect(localAddr, 9999);
Stream stream = client.GetStream();
BinaryReader reader = new BinaryReader(stream);
BinaryWriter writer = new BinaryWriter(stream);
writer.Write("Hello from Client");
String Str=reader.ReadString();
Console.WriteLine(Str);
Console.ReadLine();
}
 
Ad

Advertisements

P

Paul G. Tobey [eMVP]

Forget the emulator. Some network stuff works from there, but you *do not*
want to use it for programs which are primarily network programs. Use the
real device.

Paul T.

John Olbert said:
We are trying to run a Server App on WinCe and communicate with it
(sending
an string back and forth) from another App running on the desktop. We are
using WinCe Emulator.

On this Newsgroup it was suggested that we try sockets. I am trying this
now. Code is below.

When I tried both ends using th localhost ("127.0.0.1") I got this error--
"An unhandled exception of type 'System.Net.Sockets.SocketException'
occurred in system.dll
Additional information: No connection could be made because the target
machine actively refused it"

I then doubleclicked the network icon on the WinCe Emulator, got the Ip of
the WinCe Emulator and tried it. I got this error--
"Additional information: A connection attempt failed because the connected
party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond"

The intented use for WinCe and the NetCf is to have an App running on a
PCB
in an analytical instrument we manufacture for chemists. This PCB may have
a
screen. The instrument will be connected to a computer in some manner.
Either
Rs232, USB or a network connection (i.e., RJ45 connector). I am not sure
what
they plan at this point. I am trying to learn how to develop Apps using
NetCf
and Vs2003 IDE for both the desktop side and the PCB side (i.e., the
analytical instrument). I am using the WinCe Emulator for the learning
curve. The PCB is not available yet.

I have been reading various articles. I can create in C# App's (Console
and
Form based) that run on the Emulator. So far in the articles I have read
there is little discussion of how a desktop App might communicate (both
ways)
with a WinCe App. Sockets with it's event like behavior would be fine.

Any suggestions would be appreciated.

--John Olbert
(e-mail address removed)

I used the following code in Console Apps that failed--
On WinCe side (the socket server)--
static void Main(string[] args)
{
//IPAddress localAddr = IPAddress.Parse("127.0.0.1");
IPAddress localAddr = IPAddress.Parse("192.168.131.72"); //this is the Ip
from within WinCe
TcpListener listener = new TcpListener(localAddr, 9999);
Console.WriteLine("Waiting for initial connection");
listener.Start();
Socket socket = listener.AcceptSocket();
Console.WriteLine("Connected");
NetworkStream stream = new NetworkStream(socket);
BinaryReader reader = new BinaryReader(stream);
BinaryWriter writer = new BinaryWriter(stream);
String Str=reader.ReadString();
Console.WriteLine(Str);
writer.Write("Hello from Server");
Console.ReadLine();
}

On the desktop side--
static void Main(string[] args)
{
IPAddress localAddr = IPAddress.Parse("192.168.131.72");
TcpClient client = new TcpClient();
//client.Connect("localhost", 9999);
client.Connect(localAddr, 9999);
Stream stream = client.GetStream();
BinaryReader reader = new BinaryReader(stream);
BinaryWriter writer = new BinaryWriter(stream);
writer.Write("Hello from Client");
String Str=reader.ReadString();
Console.WriteLine(Str);
Console.ReadLine();
}
 
G

Guest

Unfortunately the device will not be available for a bit of time. I will
have to work with other aspects of the NetCf (plenty to learn).

Could you just confirm that sockets would be a viable means of communicating
between a WinCe device and a desktop?

Thanks for the information. It saves me spending time trying to make the
unworkable work.

--John Olbert
(e-mail address removed)

Paul G. Tobey said:
Forget the emulator. Some network stuff works from there, but you *do not*
want to use it for programs which are primarily network programs. Use the
real device.

Paul T.

John Olbert said:
We are trying to run a Server App on WinCe and communicate with it
(sending
an string back and forth) from another App running on the desktop. We are
using WinCe Emulator.

On this Newsgroup it was suggested that we try sockets. I am trying this
now. Code is below.

When I tried both ends using th localhost ("127.0.0.1") I got this error--
"An unhandled exception of type 'System.Net.Sockets.SocketException'
occurred in system.dll
Additional information: No connection could be made because the target
machine actively refused it"

I then doubleclicked the network icon on the WinCe Emulator, got the Ip of
the WinCe Emulator and tried it. I got this error--
"Additional information: A connection attempt failed because the connected
party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond"

The intented use for WinCe and the NetCf is to have an App running on a
PCB
in an analytical instrument we manufacture for chemists. This PCB may have
a
screen. The instrument will be connected to a computer in some manner.
Either
Rs232, USB or a network connection (i.e., RJ45 connector). I am not sure
what
they plan at this point. I am trying to learn how to develop Apps using
NetCf
and Vs2003 IDE for both the desktop side and the PCB side (i.e., the
analytical instrument). I am using the WinCe Emulator for the learning
curve. The PCB is not available yet.

I have been reading various articles. I can create in C# App's (Console
and
Form based) that run on the Emulator. So far in the articles I have read
there is little discussion of how a desktop App might communicate (both
ways)
with a WinCe App. Sockets with it's event like behavior would be fine.

Any suggestions would be appreciated.

--John Olbert
(e-mail address removed)

I used the following code in Console Apps that failed--
On WinCe side (the socket server)--
static void Main(string[] args)
{
//IPAddress localAddr = IPAddress.Parse("127.0.0.1");
IPAddress localAddr = IPAddress.Parse("192.168.131.72"); //this is the Ip
from within WinCe
TcpListener listener = new TcpListener(localAddr, 9999);
Console.WriteLine("Waiting for initial connection");
listener.Start();
Socket socket = listener.AcceptSocket();
Console.WriteLine("Connected");
NetworkStream stream = new NetworkStream(socket);
BinaryReader reader = new BinaryReader(stream);
BinaryWriter writer = new BinaryWriter(stream);
String Str=reader.ReadString();
Console.WriteLine(Str);
writer.Write("Hello from Server");
Console.ReadLine();
}

On the desktop side--
static void Main(string[] args)
{
IPAddress localAddr = IPAddress.Parse("192.168.131.72");
TcpClient client = new TcpClient();
//client.Connect("localhost", 9999);
client.Connect(localAddr, 9999);
Stream stream = client.GetStream();
BinaryReader reader = new BinaryReader(stream);
BinaryWriter writer = new BinaryWriter(stream);
writer.Write("Hello from Client");
String Str=reader.ReadString();
Console.WriteLine(Str);
Console.ReadLine();
}
 
Ad

Advertisements

P

Paul G. Tobey [eMVP]

Sure. Any sort of network communication between the desktop and the device
is highly likely to be based on sockets. It's down near the bottom of
virtually any method you might think of.

If you have outgoing sockets from your device program, you can make that
work from the emulator; server sockets, however, are very hard to connect to
when they are running in the emulator.

Paul T.

John Olbert said:
Unfortunately the device will not be available for a bit of time. I will
have to work with other aspects of the NetCf (plenty to learn).

Could you just confirm that sockets would be a viable means of
communicating
between a WinCe device and a desktop?

Thanks for the information. It saves me spending time trying to make the
unworkable work.

--John Olbert
(e-mail address removed)

Paul G. Tobey said:
Forget the emulator. Some network stuff works from there, but you *do
not*
want to use it for programs which are primarily network programs. Use
the
real device.

Paul T.

John Olbert said:
We are trying to run a Server App on WinCe and communicate with it
(sending
an string back and forth) from another App running on the desktop. We
are
using WinCe Emulator.

On this Newsgroup it was suggested that we try sockets. I am trying
this
now. Code is below.

When I tried both ends using th localhost ("127.0.0.1") I got this
error--
"An unhandled exception of type 'System.Net.Sockets.SocketException'
occurred in system.dll
Additional information: No connection could be made because the target
machine actively refused it"

I then doubleclicked the network icon on the WinCe Emulator, got the Ip
of
the WinCe Emulator and tried it. I got this error--
"Additional information: A connection attempt failed because the
connected
party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond"

The intented use for WinCe and the NetCf is to have an App running on a
PCB
in an analytical instrument we manufacture for chemists. This PCB may
have
a
screen. The instrument will be connected to a computer in some manner.
Either
Rs232, USB or a network connection (i.e., RJ45 connector). I am not
sure
what
they plan at this point. I am trying to learn how to develop Apps using
NetCf
and Vs2003 IDE for both the desktop side and the PCB side (i.e., the
analytical instrument). I am using the WinCe Emulator for the learning
curve. The PCB is not available yet.

I have been reading various articles. I can create in C# App's (Console
and
Form based) that run on the Emulator. So far in the articles I have
read
there is little discussion of how a desktop App might communicate (both
ways)
with a WinCe App. Sockets with it's event like behavior would be fine.

Any suggestions would be appreciated.

--John Olbert
(e-mail address removed)

I used the following code in Console Apps that failed--
On WinCe side (the socket server)--
static void Main(string[] args)
{
//IPAddress localAddr = IPAddress.Parse("127.0.0.1");
IPAddress localAddr = IPAddress.Parse("192.168.131.72"); //this is the
Ip
from within WinCe
TcpListener listener = new TcpListener(localAddr, 9999);
Console.WriteLine("Waiting for initial connection");
listener.Start();
Socket socket = listener.AcceptSocket();
Console.WriteLine("Connected");
NetworkStream stream = new NetworkStream(socket);
BinaryReader reader = new BinaryReader(stream);
BinaryWriter writer = new BinaryWriter(stream);
String Str=reader.ReadString();
Console.WriteLine(Str);
writer.Write("Hello from Server");
Console.ReadLine();
}

On the desktop side--
static void Main(string[] args)
{
IPAddress localAddr = IPAddress.Parse("192.168.131.72");
TcpClient client = new TcpClient();
//client.Connect("localhost", 9999);
client.Connect(localAddr, 9999);
Stream stream = client.GetStream();
BinaryReader reader = new BinaryReader(stream);
BinaryWriter writer = new BinaryWriter(stream);
writer.Write("Hello from Client");
String Str=reader.ReadString();
Console.WriteLine(Str);
Console.ReadLine();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top