@ Omen
I will write some example code over Easter.
Quote: "You know the examples I'd love to see would be some examples of how to use multiple server listener instances now under 2.0 in dbpro. Perhaps, though, instancing doesn't make sense in dbpro? Not sure there really. Let's see what else..."
You can run two servers from one application just by setting up two servers on different instance IDs.
Quote: "I seem to remember something about adding a "broadcast to channel" capability, but now can't find anything like that in the mn namespace. Not sure if that's implemented or not, but if so would love to see how to do it."
You can use broadcasting to send a packet to all clients on a network without connecting directly to them. This has changed a little from v1 and is slightly buggy in that the way you use it differs from how the documentation tells you to use it... I will fix this over Easter too. See this code for how you can get it working:
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$ = "192.168.0.7"
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,0,1,profileSend
mn start broadcast BROADCAST_RECV_INSTANCE,IP$,0,1,0,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