UDP packets not received by desktop PC

C

Chin

Hi,

I'm trying to write an app on PocketPC that will send some data to
desktop PC when the PocketPC is connected to the PC via USB cable
(ActiveSync). So my first question is, besides UDP, is there any other
way to do it? I don't want any user interaction (e.g. prompt the user
to enter IP address of the PC). I'll have an app sitting on the
desktop to receive the data.

Currently I'm using the UDP approach and the problem that I'm facing
is, the UDP server app on my desktop does not receive anything from
the PocketPC. Below is the code I extracted from both the PocketPC app
and desktop app.

Thanks!

---Pocket PC [Begin] ---
Private Function TestUdp() As String

Dim client As New Sockets.UdpClient
Dim queryString As String
Dim output() As Byte
Dim msg() As Char
Dim remoteIpEndPoint As IPEndPoint
Dim ipAdd As IPAddress

remoteIpEndPoint = New IPEndPoint(IPAddress.Broadcast, 12345)
queryString = "How are you?"
msg = queryString.ToCharArray()
output = System.Text.Encoding.ASCII.GetBytes(msg)
client.Send(output, output.Length, remoteIpEndPoint)
client.Close()
End Function
---Pocket PC [End] ---

---Desktop [Begin] ---

private void ReceiveData()
{
try
{
UdpClient client = new UdpClient(12345);
IPEndPoint remoteEP = new IPEndPoint(IPAddress.Any, 0);
byte[] result;
String resultStr = "";

result = client.Receive(ref remoteEP);
resultStr = System.Text.Encoding.ASCII.GetString(result, 0,
result.Length);
MessageBox.Show(resultStr);
client.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
---Desktop [End] ---
 

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