UDP Broadcast (was Re: Program Linking)
Dar Scott
dsc at swcp.com
Tue Mar 19 15:13:01 EST 2002
On Tuesday, March 19, 2002, at 12:32 PM, Ian Summerfield wrote:
> 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 get 112.85.12.116, too, and 0.124.79.247 looks familiar. I get
the same kind of behavior. Only I don't get messages from your
UPS. ;-)
> 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
Or something like this (ignoring stopping the thing for now for now):
on mouseUp
accept datagram connections on port 3052 with message "gotGram"
end mouseUp
on gotGram fromwhom,what
if what is not empty then
-- do whatever I want with the data
close socket 3052
accept datagram connections on port 3052 with message "gotGram"
end if
end gotGram
This assumes some minimum time between datagrams, of course.
Datagrams that come in in the close-accept window will be lost. In
applications like yours where you know the minimum interval, that
is OK. That is OK in another large class of applications where a
few lost messages are tolerated.
If this works, I like this better, because I have no idea whether
the read from an "accept datagram" is supposed to work and will
work later or on other platforms.
Part of my problem in thinking about this is not knowing if OS X
UDP will be fixed next week, in six months or never.
Dar
More information about the use-livecode
mailing list