You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.
Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.
UDPMode as integer
Port = 6789
LocalIP$ = ""
ConnectToIP$ = "192.168.1.2"
UDPMode = 3
SendPacket = mn create packet()
RecvPacket = mn create packet()
mn set memory size SendPacket,1024
mn Start 1,0
profile = mn create instance profile()
mn set profile local udp profile,LocalIP$,Port
mn set profile mode udp profile,UDPMode
Result = mn start broadcast(0, "255.255.255.255",6789,1,1,profile)
if (Result = 0)
print "Broadcast started"
print "Broadcast local UDP port: " + str$(mn get local port udp(0))
print "Broadcast local IP: " + mn get local ip udp(0)
print "Broadcast did not start"
bkeydown as boolean
// Send packet on 'S' key.
if (a$ <> "")
if (bkeydown = false)
bkeydown = true
if (a$ = "s")
mn add string SendPacket,"jambo",0,1
mn send udp 0,SendPacket,0,0,0
bkeydown = false
// Any UDP packets received?
UDPPackets = mn Recv udp(0,RecvPacket,0,0)
if (UDPPackets > 0)
b$ = mn get string(RecvPacket,0,1)
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()
sync sleep 1
if timer() - sendTimer >= sendFreq
mn send udp BROADCAST_SEND_INSTANCE,sendPacket,0,1,0
sendTimer = timer()
print "Sent broadcast packet"
recvAmount = mn recv udp(BROADCAST_RECV_INSTANCE,recvPacket,0,0)
if recvAmount > 0
print "Received broadcast packet: " + mn get string(recvPacket,0,1)
Login to post a reply