UDP Broadcast (was Re: Program Linking)

Ian Summerfield iansummerfield at btconnect.com
Tue Mar 19 14:34:00 EST 2002


On 18/3/02 12:38 am, "Dar Scott" <dsc at swcp.com> scribed:

>> on mouseup
>>   accept datagram connections on port 3052 with message "gotGram"
>> end mouseup
>> 
>> on gotGram fromwho,what
>>   if what is not empty then
>>     -- do whatever I want with the data
>>   end if
>>   read from socket 3052 with message "gotGram"
>> end gotGram
> 
> This has a problem on my system (OS X with R 1.1.1 RC1).  You might
> have it in yours.  Try it with a beep or counter at the end of your
> "gotGram" handler.  I get a call back with an empty datagram not
> only the first time but also repeatedly about 100 times a second.
> Then I get socket timeout callbacks, even when I'm receiving
> datagrams.

This does indeed cause lots of beeps.  I realised that was happening and
wondered if it's harmful to anything.   Anyway, it appears it is.  I left
the code running all night on OS X.  By morning 150MB of remaining disk
space had vanished - I don't know why but I blame Revolution.  After running
all night Revolution was unusable because it was bogged down doing
something,  thrashing the hard drive and on selecting quit it had the
colourful spinning cursor in OS X stuck there and took about 15 minutes to
quit.

Anyway, I've since discovered, all those extra datagram's with no data in
them also have an invalid sender IP address:

112.85.12.116|55011528 <<-- initial accept command!
192.168.1.50|55011528  <<- valid data coming in every 26 seconds
0.124.79.247|55011528  <<-- this one is repeated hundreds!
192.168.1.50|55011528  <<- valid data coming in every 26 seconds
0.124.79.247|55011528  <<-- this one is repeated hundreds!

I'm thinking that because I know my device only sends a message every 26
seconds that I'll have to implement this workaround:

on mouseup
  accept datagram connections on port 3052 with message "gotGram"
end mouseup

on gotGram fromwho,what
  if what is not empty then
    -- do whatever I want with the data
  end if
  put the pendingmessages into pm
  if "getgram" is not in pm then send "getGram" to me in 25 seconds
end gotGram

on getGram
  beep
  read from socket 3052 with message "gotGram"
end getGram




More information about the use-livecode mailing list