Sarah,

Thanks for the reply.

After a lot of testing on Mac OS X, I've found that the problem I was having appears to be due to the way that Mac OS X does DNS lookups. Whether or not it's a RunRev bug as well is hard to tell, but I think it might be.

Here's some sample code I wrote. This code sends a "My5SecondTimeout" message to itself, opens a socket, makes an HTTP GET request, waits for the response, and closes the socket. (Note: I had to use this "My5SecondTimeout" message because setting the socketTimeoutInterval doesn't seem to work).

When you run this script and you're not connected to the internet here's what happens:

1) If I open the socket with an ip address, e.g. 64.125.128.80, my 5 second timer will fire, and I can close the socket and exit from the routine.

2) If I open the socket with a domain address, e.g. www.webphotospro.com, Mac OS X does a DNS lookup, puts up the rainbow rotating color cursor, and hangs until the DNS lookup fails. On my machine this takes 60 seconds (apparently it's dependent on how many dns servers you have listed).

I'm guessing this is a RunRev bug, but I can't be sure. Basically RunRev hangs for 60 seconds while the DNS lookup takes place during the "open socket" call -- it doesn't send a socket timeout, and it doesn't the "My5SecondTimeout" message either.

Can confirm this?

Thanks,
-- Frank

on mouseUp
set the socketTimeoutInterval to 5000 -- this seems to do nothing, but set it anyway
global theIp, socketIsOpen, socketTimedOut
put "www.webphotospro.com:80" into theIp -- using this causes RunRev to hang for 60 seconds
-- put "64.125.128.80:80" into theIp -- using this does not cause a hang
put false into socketIsOpen
put false into socketTimedOut


send "My5SecondTimeout" to button "Ping" in 5 seconds -- send a message to myself
close socket theIp -- in case it's currently open
open socket to theIp with message "mySocketOpenMsg"
wait until socketIsOpen or socketTimedOut with messages
if socketTimedOut then
close socket theIp
answer "socket timed out"
end if
end mouseUp


on My5SecondTimeout
  global socketIsOpen, socketTimedOut
  if not socketIsOpen then
    put true into socketTimedOut
  end if
end My5SecondTimeout

on mySocketOpenMsg theParams
global theIp, socketIsOpen
put true into socketIsOpen
write "GET / HTTP/1.0" & numToChar(13) & numToChar(10) & numToChar(13) & numToChar(10) to socket theIp
read from socket theIp for 50 with message "mySocketReadDoneMsg"
end mySocketOpenMsg


on mySocketReadDoneMsg socketId, theData
  global theIp
  close socket theIp
  answer "read done: " & socketId && theData
end mySocketReadDoneMsg

Web Photos Pro: Software for Photo Bloggers and Other Photo Power Users
See us on the web at http://www.webphotospro.com/

On Jan 31, 2005, at 1:16 AM, [EMAIL PROTECTED] wrote:

From: Sarah Reichelt <[EMAIL PROTECTED]>
Subject: Re: Socket timeout not working with libUrl
To: How to use Revolution <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=US-ASCII; format=flowed

My product pings the Web Photos Pro website to look for new versions.
This works great when the computer the product's running on is
connected to the internet, but it hangs for 60 seconds when there's no
net connection.

My code looks like this:

  set the socketTimeoutInterval to 5000
  put URL (getPhotoAlbumUrl() & "downloads/version_info.php") into
newVersion

Is there any way I can force a timeout after 5 seconds?  Should I be
using a non-blocking URL request?  Should I be attempting to open a
socket directly to do an initial "am I connected to the internet?"
request, before making the URL request?


Hi Frank,

I would definitely use a non-blocking request, so the user won't even
notice if it is trying & failing.
Try something like:
   set the socketTimeoutInterval to 5000
   put (getPhotoAlbumUrl() & "downloads/version_info.php") into tURL
   load tURL with message gotVersion

Then you need a "gotVersion" handler in the same object:

on gotVersion
   put URL (getPhotoAlbumUrl() & "downloads/version_info.php") into
newVersion
   -- check newVersion & do the usual stuff
end gotVersion

Hope this helps,
Sarah

_______________________________________________ use-revolution mailing list [email protected] http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to