From: eljainc on
Hello,

I am trying to develop an application on a PocketPC phone using VS2005
in C#.
The application simply waits for messages from the client (the
PocketPC acts
like the server)

I am using some code which looks like:

private void myMonitor()
{
try
{
// Set the TcpListener on port 13000.
int port = 13000;
IPAddress localAddr = IPAddress.Parse("169.254.50.100");
bool messageReceived = false;
// TcpListener server = new TcpListener(port);
TcpListener server = new TcpListener(port);
//(localAddr, port);
//localAddr, port);

// Start listening for client requests.
server.Start();
while(!messageReceived)

{

// You could also user server.AcceptSocket() here.
TcpClient client = server.AcceptTcpClient();
int i;

// Loop to receive all the data sent by the client.
while((i = stream.Read(bytes, 0, bytes.Length))!=0)
{
// Translate data bytes to a ASCII string.
data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
}
/ Shutdown and end connection
client.Close();
messageReceived = true;
server.Stop();
}
catch(SocketException e)
{
Console.WriteLine("SocketException: {0}", e);
}


However, sometimes I am getting no communications from the client.
This is in particular if I use the following override of TcpListener:

TcpListener server = new TcpListener(localaddr, port);

Is there another way that I can get better communications (wireless)
on a PocketPC?

Thanks
Mike