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();
}
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();
}