[CODE] "New Connection" code.

From: Andrew Ritchie (object@alphalink.com.au)
Date: 02/15/99

  while (!circle_shutdown) {
    /* Sleep if we don't have any connections */
    if (descriptor_list == NULL) {
      log("No connections.  Going to sleep.");
      FD_SET(mother_desc, &input_set);
      if (select(mother_desc + 1, &input_set, (fd_set *) 0, (fd_set *) 0,
NULL) < 0) {
        if (errno == EINTR)                    <-
          log("Waking up to process signal."); <-
        else                                   <-
          perror("Select coma");               <-
      } else                                   <-
        log("New connection.  Waking up.");    <-
      gettimeofday(&last_time, (struct timezone *) 0);

I'm a bit stuck on this code. I'm not quite sure how it works, around the
lines indicated with a "<-". It seems to me one of three things can happen
in the if..else statement. Either you'll get a message to the logfile saying
"Waking up to process signal.", you'll get an error "Select coma", or you'll
get a "New connection. Waking up." message to your log files. When I compile
my MUD, and run it, none of these statements gets executed whilst there is
no one on the MUD. Why is this? Somehow it skips the entire section.

It works fine, but I just can't see how it actually works. If someone can
give me an idea of why it works and how it seemingly skips the if statements
I would be very grateful.


Andrew Ritchie,

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |

This archive was generated by hypermail 2b30 : 12/15/00 PST