Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Wait for port/time, can you tell which is which?

From: mat::eurogamer::net at: 15-Jun-2001 11:10

Hello folks, This is a straightforward problem and I'm sure I'm missing something obvious. However any help appreciated! I've written this IRC bot in Rebol and it's absolutely marvellous if I do say so myself. :) The only problem is that it can sometimes be disconnected from the server and it doesn't know about it. The same happens to regular IRC clients too. As soon as you try to send something, then it's apparent you have no socket and the bot/IRC client reconnects etc. No problem. The issue is using wait <port>, this will quite happily wait forever obviously. I understand you can wait for a port AND a time, which is nice. However, how could you tell whether wait has returned because the duration timed out or that there was data at the port? If there was no data and the wait timed out because of the duration, currently I wouldn't know. I'd executing some sort of read from the port which would result in a null string. You'd take that to mean that the port is closed, right? Which is no good. Instead, if the wait has timed out because of the TIME limit then I just want to send some data to the server (a simple ping in this case) and go back to my wait. If the socket is dead, then the wait would return having data (even if there is none) and the bot would reconnect because it was appropriate. So how can you tell or is this the wrong approach entirely? Phew. -- Mat Bettinson - EuroGamer's Gaming Evangelist with a Goatee |