UDP Broadcast (was Re: Program Linking)

Dar Scott dsc at swcp.com
Sun Mar 17 19:43:01 EST 2002


On Sunday, March 17, 2002, at 04:23 PM, Ian Summerfield wrote:

> I didn't know any of what you said.  I'm working on OS X, and this 
> evening
> just finished a little project to monitor an APC UPS.  I used "accept
> datagram" but then found the "have some work to do" bit you refer 
> to was
> only a case of calling "read from socket nnnn with message xxxxxx" 
> at the
> end of my message handler.   It works fine.   Is this the proper 
> approach?

I don't know if it is proper.  I didn't even think of the idea.  I 
didn't even know the "read from socket" callbackMessage had a 
second parameter until I saw it in the dictionary for Revolution 
1.1.1 RC1.


> 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.

What I had in mind for "have some work to do" was closing and and 
accepting again after each valid datagram.

Dar Scott
Dar Scott Consulting
Albuquerque




More information about the use-livecode mailing list