cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Problem in connect.c with socket() call.

From: <John.Clayton_at_barclayscapital.com>
Date: Mon, 18 Mar 2002 10:08:39 -0000

Sorry, would like to mention that the formatting did not appear in this mail
(should have thought of that)

Here's the simple highlighting to show the location of the code with the
error...

  /* create an IPv4 TCP socket */
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if(-1 == sockfd)
  {
                ... try to recover with a sock call containing PF_INET ...
  }

Regards
 John Clayton.

-----Original Message-----
From: John.Clayton_at_barclayscapital.com
[mailto:John.Clayton_at_barclayscapital.com]
Sent: 18 March 2002 10:02
To: curl-library_at_lists.sourceforge.net
Subject: Problem in connect.c with socket() call.

Hi All

We've got a problem with socket creation when using curl - if anyone has a
little time to help us out we'd really appreciate it. Thanks in advance.
What follows is a problem / background description.

The problem
Sometimes, our apps are unable to complete their curl library socket()
calls. The error occurs within connect.c of the curl library, on line 594
(version 7.9.4). The error we're getting is WSAEPROTONOSUPPORT, running on
Windows NT SP3.

The background
Our app uses curl as way of performing DB queries across a network using
http get&post. Therefore there are LOTS of small requests being made in the
course of usual operation. We form up HTTP requests, and always spit XML
out from our servers - which is received and processed by Curl and then fed
into James Clarke's expat library (anyone know interop. issues with these
two libs?).

Our attempts to find out what's happening
- We cut/paste of our production code into an existing test harness which
loops across 2000 times with one of our more common queries - no problems
found.
- Changed the Curl code to check the result of the create socket() call -
here's what our connect.c @ line 459, using curl 7.9.4 - this is the
location of the failure - but changing to PF_INET didn't help
  /*
   * Connecting with IPv4-only support
   */
  if(!remotehost->h_addr_list[0]) {
    /* If there is no addresses in the address list, then we return
       error right away */
    failf(data, "no address available");
    return CURLE_COULDNT_CONNECT;
  }
  /* create an IPv4 TCP socket */
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if(-1 == sockfd)
  {
      // Have another go with the correct protocol
    sockfd = socket(AF_INET, SOCK_STREAM, PF_INET);
    if(-1 == sockfd)
    {
      int Err = WSAGetLastError();
      char b[200];
      sprintf(b, "couldnt create socket, err is %d", Err);
      failf(data, b);
      return CURLE_COULDNT_CONNECT; /* big time error */
    }
  }

Thanks again if you made it this far. If anyone has clues or ideas that we
could try in order to find (and submit a patch if we *do* find something),
we're all ears!!

John Clayton
Barclays Capital
xt 33624

------------------------------------------------------------------------
For more information about Barclays Capital, please
visit our web site at http://www.barcap.com.

Internet communications are not secure and therefore the Barclays
Group does not accept legal responsibility for the contents of this
message. Although the Barclays Group operates anti-virus programmes,
it does not accept responsibility for any damage whatsoever that is
caused by viruses being passed. Any views or opinions presented are
solely those of the author and do not necessarily represent those of the
Barclays Group. Replies to this email may be monitored by the Barclays
Group for operational or business reasons.

------------------------------------------------------------------------
Received on 2002-03-18