title: Operation now in progress error on connect( function) error
body: <p>I want to set timeout value of function connect but I get this error: "Operation now in progress"</p>
  
  <p>My code:</p>
  
  <pre><code>if ((he = gethostbyname(authdefhost)) == NULL) {
          snprintf(errbuf, CERRBUFSIZ - 1, "cannot resolve %s: %s\n", authdefhost, hstrerror(h_errno));
          return -1;
  }
  
  sin.sin_family = AF_INET;
  memcpy(&amp;sin.sin_addr, he-&gt;h_addr_list[0], sizeof(struct in_addr));       
  
  if ((sd = socket(AF_INET, SOCK_STREAM, 0)) &lt; 0) {
          snprintf(errbuf, CERRBUFSIZ - 1, "cannot create client socket: %s\n", strerror(errno));
          return -1;
  }
  
  if ((fcntl(sd, F_SETFL, O_NONBLOCK) &lt; 0))
      printf("error on setting socket flags.");
  
  if (connect(sd, (void *) &amp; sin, sizeof(sin)) == -1) {
          snprintf(errbuf, CERRBUFSIZ - 1, "cannot connect to server %s: %s\n", authdefhost, strerror(errno));
          close(sd);
          return -1;
  }
  
  FD_ZERO(&amp;fdset);
  FD_SET(sd, &amp;fdset);
  int rv;
  if ((rv = select(sd + 1, NULL, &amp;fdset, NULL, &amp;tv)) == -1) {
      printf("error occurred on select function.");
      return -1;
  }
  else if (rv == 0) {
      printf("time out occurred.");
      return -1;
  }
  else {
      printf("connection established");
      return sd;
  }
  </code></pre>