D
davis
Hi - I'm writing udp socket program between laptop and pocket pc (CF
2.0). I construct and send UDP datagrams, and they never appear. The
medium is Wi-Fi. I've done the following:
a) verified ping between the two hosts
b) launched ethereal to sniff for the packets -- they never show.
however, i do see plenty of other packets...and a whole lot of busy TCP
traffic between the hosts in ethereal.
c) checked, and double-checked address and port numbers
This code is the same on both sides, and initializes the socket and
binds to it:
if (sock == null) {
try {
locIpEndPoint = new
IPEndPoint(IPAddress.Parse(address.LocalIp), address.LocalIpPort);
sock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
sock.Bind(locIpEndPoint);
Debug.WriteLine("Bound to socket: " +
locIpEndPoint);
} catch (SocketException ex) {
HandleException(ex);
this.Close();
}
}
This prints:
Bound to socket: 192.168.10.36:9999 on the laptop
Bound to socket: 192.168.10.103:9998 on the pocketpc
Here is the code that sends udp datagrams from the pocketpc to the
laptop
try {
// start async reader
IAsyncResult result = sock.BeginReceiveFrom(buffer,
0, buffer.Length, SocketFlags.None,
ref remEp, new AsyncCallback(ReceivedData),
sock);
while (discoveryStarted) {
Debug.WriteLine("Sending the bytes: " +
BitConverter.ToString(bytes) + " to " + remIpEndPoint);
sock.SendTo(bytes, SocketFlags.None,
remIpEndPoint);
// throttle the sender to one-second
Thread.Sleep(1000);
}
This repeatedly prints:
Sending the bytes: 01-06-D0-67-0A-A8-C0-0E-27-0D to 192.168.10.36:9999
On the laptop (192.168.10.36), I run ethereal (packet sniffer) and I
never see the UDP packets, but I do see a bunch of TCP traffic between
192.168.10.36 and 192.168.10.103 so I know there is connectivity.
I'm really scratching my head here. I do have a Socket.BeginRead( ) on
the laptop which never fires, but this only caused me to use a packet
sniffer to see if the packets were being sent over the air. Am I
missing something really fundamental here?
Thanks in advance,
Davis
2.0). I construct and send UDP datagrams, and they never appear. The
medium is Wi-Fi. I've done the following:
a) verified ping between the two hosts
b) launched ethereal to sniff for the packets -- they never show.
however, i do see plenty of other packets...and a whole lot of busy TCP
traffic between the hosts in ethereal.
c) checked, and double-checked address and port numbers
This code is the same on both sides, and initializes the socket and
binds to it:
if (sock == null) {
try {
locIpEndPoint = new
IPEndPoint(IPAddress.Parse(address.LocalIp), address.LocalIpPort);
sock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
sock.Bind(locIpEndPoint);
Debug.WriteLine("Bound to socket: " +
locIpEndPoint);
} catch (SocketException ex) {
HandleException(ex);
this.Close();
}
}
This prints:
Bound to socket: 192.168.10.36:9999 on the laptop
Bound to socket: 192.168.10.103:9998 on the pocketpc
Here is the code that sends udp datagrams from the pocketpc to the
laptop
try {
// start async reader
IAsyncResult result = sock.BeginReceiveFrom(buffer,
0, buffer.Length, SocketFlags.None,
ref remEp, new AsyncCallback(ReceivedData),
sock);
while (discoveryStarted) {
Debug.WriteLine("Sending the bytes: " +
BitConverter.ToString(bytes) + " to " + remIpEndPoint);
sock.SendTo(bytes, SocketFlags.None,
remIpEndPoint);
// throttle the sender to one-second
Thread.Sleep(1000);
}
This repeatedly prints:
Sending the bytes: 01-06-D0-67-0A-A8-C0-0E-27-0D to 192.168.10.36:9999
On the laptop (192.168.10.36), I run ethereal (packet sniffer) and I
never see the UDP packets, but I do see a bunch of TCP traffic between
192.168.10.36 and 192.168.10.103 so I know there is connectivity.
I'm really scratching my head here. I do have a Socket.BeginRead( ) on
the laptop which never fires, but this only caused me to use a packet
sniffer to see if the packets were being sent over the air. Am I
missing something really fundamental here?
Thanks in advance,
Davis