v2.0.1 fixes broadcasting, the following code works:
mn start 2,0
` Broadcast IP tells router to send message to all clients on LAN.
broadcastIP$ = "255.255.255.255"
` Local address that we are sending from.
IP$ = ""
port = 24000
` Bind to local IP, but retrieve a random port.
profileSend = mn create instance profile()
mn set profile local profileSend,IP$,0,IP$,0
` Bind to local IP and port so that we can retrieve data broadcast to that port.
profileRecv = mn create instance profile()
mn set profile local profileRecv,IP$,port,IP$,port
` Setup two instances, one for broadcasting and one for receiving broadcasts.
` Currently this is a bit buggy, both send and receive are enabled for both instances
` (parameters are ignored), and the instance profiles are not accessed, the connectToIP
` and connectToPort are the local IP and port used (contrary to what the documentation says).
` This will be changed so that instance profiles effect local bindings in the next update.
#constant BROADCAST_SEND_INSTANCE = 0
#constant BROADCAST_RECV_INSTANCE = 1
mn start broadcast BROADCAST_SEND_INSTANCE,broadcastIP$,port,1,0,profileSend
mn start broadcast BROADCAST_RECV_INSTANCE,IP$,0,0,1,profileRecv
sendFreq = 1000
sendTimer = 0
sendPacket = mn create packet()
myUniqueString$ = get time$()
mn add string sendPacket, myUniqueString$,0,1
recvPacket = mn create packet()
do
sync sleep 1
if timer() - sendTimer >= sendFreq
mn send udp BROADCAST_SEND_INSTANCE,sendPacket,0,1,0
sendTimer = timer()
print "Sent broadcast packet"
endif
recvAmount = mn recv udp(BROADCAST_RECV_INSTANCE,recvPacket,0,0)
if recvAmount > 0
print "Received broadcast packet: " + mn get string(recvPacket,0,1)
endif
loop
Note that you always need 2 separate instances to send and receive, one instance can't do both.