title: Hang at connect()
body: <p>So, I have a client that attempts to connect with a server.  The ip and port are retrieved from a configuration file.  I need the program to fail smoothly if something in the config file is incorrect.  I connect to the server using the following code</p>
  
  <pre><code>if (connect(sockfd, p-&gt;ai_addr, p-&gt;ai_addrlen) == -1)
  {
      perror("client: connect");
      close(sockfd);
      continue;
  }
  </code></pre>
  
  <p>If the user attempts to connect to a server on the subnet that is not accepting connections (i.e. is not present), then the program fails with <code>No route to host</code>.  If the program attempts to connect to a server that is not on the subnet (i.e. the configuration is bad), then the program hangs at the <code>connect()</code> call.  What am I doing incorrectly?  I need this to provide some feedback to the user that the application has failed.</p>