cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: connect() select() poll() checking against -1 return values

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 19 Nov 2008 14:34:36 +0100 (CET)

On Tue, 18 Nov 2008, Jeff_Curley_at_playstation.sony.com wrote:

> If libcurl had chosen to mask away the socket implementation calls such as
> using _connect, _recv, _send, etc., I could have macro'd my changes away
> easily in my config-ps3.h file.

Right, but libcurl has taken the opposite approach and thus _you_ can do the
masking away of your system's internals! We've deliberately assumed a
POSIX-like API and that implies -1 for errors.

You should be able to do something similar to this:

/* in a header libcurl uses: */
#define connect(x,y,z) my_connect(x,y,z)

/* in source code that libcurl links with: */
int my_connect(int socket, const struct sockaddr *address,
                socklen_t address_len)
{
   int rc = (connect)(socket, address, address_len);
   if(rc < 0) {
      errno = rc;
      rc = -1;
   }

   return rc;
}

> But the good news is, it works on PS3 with minimal changes, which is a
> testament to this communities hard work.

Cool news, thanks for letting us know!

-- 
  / daniel.haxx.se
Received on 2008-11-19