state-threads
[Top] [All Lists]

strange code

To: state-threads@xxxxxxxxxxx
Subject: strange code
From: Lev Walkin <vlm@xxxxxxxxx>
Date: Thu, 25 Oct 2001 18:17:49 +0400 (MSD)
Sender: owner-state-threads@xxxxxxxxxxx
Hi there,


The sources (io.c) has the following function:


===

int st_connect(st_netfd_t *fd, struct sockaddr *addr, int addrlen,
               st_utime_t timeout)
{
  int n, err = 0;

  while (connect(fd->osfd, addr, addrlen) < 0) {
    if (errno != EINTR) {
      if (errno != EINPROGRESS && (errno != EADDRINUSE || err == 0))
        return -1;
      /* Wait until the socket becomes writable */
      if (st_netfd_poll(fd, POLLOUT, timeout) < 0)
        return -1;
      /* Try to find out whether the connection setup succeeded or failed */
      n = sizeof(int);
      if (getsockopt(fd->osfd, SOL_SOCKET, SO_ERROR, (char *)&err,
                     (socklen_t *)&n) < 0)
        return -1;
      if (err) {
        errno = err;
        return -1;
      }
      break;
    }
    err = 1;
  }

  return 0;
}

===


Can anybody explain the hidden meaning of

        err = 1

string?


-- 
Lev Walkin
vlm@xxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>