All
I need some help. I have a simple socket app that sends a UDP broadcast packet to my local network on a specific port. The NetDuinoPlus socket.receivefrom method doesnt get fired. However if i run as Emulator it works perfectly.
SolutionReleaseInfo.solutionVersion: 4.1.0.6 (firmware version)
Can someone tell me what i have to do to get my NetDuinoPlus to receive a UDP Broadcast packet?
My receive code is simply:
Socket sock = new Socket(AddressFamily.InterNetwork,SocketType.Dgram, ProtocolType.Udp);
IPEndPoint iep = new IPEndPoint(IPAddress.Any, 9050);
sock.Bind(iep);
EndPoint ep = (EndPoint)iep;
byte[] data = new byte[64];
int recv = sock.ReceiveFrom(data, ref ep);
There has to be something wrong here for a "Net" Duino to not receive a simple UDP Broadcast.
NetDuino Plus not Receiving UDP Broadcast Packets
Started by Homey, May 03 2012 05:55 PM
4 replies to this topic
#1
Posted 03 May 2012 - 05:55 PM
#2
Posted 04 May 2012 - 12:55 AM
... sends a UDP broadcast packet to my local network ...
SolutionReleaseInfo.solutionVersion: 4.1.0.6 (firmware version)
UDP Broadcast was broken on all firmware versions prior to 4.2 RC3.
Note: the jury is still out on UDP Multicast though, even with the 4.2 RC4.
-Valkyrie-MT
#3
Posted 04 May 2012 - 05:48 PM
UDP Broadcast was broken on all firmware versions prior to 4.2 RC3.
Note: the jury is still out on UDP Multicast though, even with the 4.2 RC4.
-Valkyrie-MT
so i should at least try to update the firmware to 4.2 RC4? If so, where do i get it?
many thanks for a response!
#5
Posted 05 May 2012 - 02:17 PM
Hi Homey,
following code I use on ND+ to receive UDP Broadcast packets
from iPhone and it works fine here with 4.1 and 4.2:
following code I use on ND+ to receive UDP Broadcast packets
from iPhone and it works fine here with 4.1 and 4.2:
private void threadStartTarget() { _socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); try { IPEndPoint broadcastEndPoint = new IPEndPoint( System.Net.IPAddress.Any, LocalPort); _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); if (Broadcast) _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); _socket.Bind(broadcastEndPoint); while (true) { EndPoint remoteEndPoint = new IPEndPoint( System.Net.IPAddress.Any, 0); int availableBytes = _socket.Available; if (availableBytes > 0) { byte[] receiveBuffer = new byte[availableBytes]; _socket.ReceiveFrom(receiveBuffer, ref remoteEndPoint); if (DataReceived != null) DataReceived(this, new DataReceivedEventArgs( receiveBuffer, remoteEndPoint)); } // This is recommends in thread loops to help prevent lock-ups Thread.Sleep(10); } } catch (Exception e) { // catch all exceptions Debug.Print(e.ToString()); } finally { doDispose(); if (SocketDone != null) SocketDone(this, EventArgs.Empty); Debug.Print("UDP server thread finished."); } }HTH, Immo
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users