I am almost certain it is because I am using UdpClient and not a Socket object.
What am I looking to do is have one object sit in listen mode, and report anything it gets back.
And use the other object to send out data (which would trigger other devices to send out datagrams that the first object should be able to pick up.)
So I have one thread that does this:
Expand|Select|Wrap|Line Numbers
- UdpClient tud = new UdpClient(1900);
- //tud.ExclusiveAddressUse = false;//Not allowed if connected or bound
- tud.EnableBroadcast = true;
- tud.MulticastLoopback = true;
- UdpState s = new UdpState();
- s.e = new IPEndPoint(IPAddress.Any, 1900);
- s.u = tud;
- Console.WriteLine("Starting to do work");
- while (_keepgoing)
- {
- Thread.Sleep(10);
- if (tud.Available>0)
- {
- IAsyncResult iar = tud.BeginReceive(new AsyncCallback(ReceiveCallback), s);
- bool tbr = iar.IsCompleted;
- }
- }
Expand|Select|Wrap|Line Numbers
- UdpClient ud = new UdpClient();
- //data is my byte[] payload
- //myBroadcast is a broadcast IPEndPoint
- int bsent = ud.Send(data, data.Length, myBroadcast);
And the thread that listens for data to come in, never sees anything.
I am going to re-work the project using the Socket object I think and see if I get better results.
If anyone has any suggestions, I would like to hear them.
EDIT: I used Sockets and still failed?