cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: <Jeff_Curley_at_playstation.sony.com>
Date: Wed, 19 Nov 2008 12:28:04 -0800

yeah I considered doing exactly that yesterday but I ran into issues with
having a macro named "connect" and pulling in the CellOS function header
for "connect" I wasn't being careful though to keep the includes separated,
so I think you are totally right and I'll give it another shot today.

Thanks Dan :)

--Jeff Curley
Sony Computer Entertainment America
Senior Programmer
(858) 824-5692

                                                                           
             Daniel Stenberg
             <daniel_at_haxx.se>
             Sent by: To
             curl-library-boun libcurl development
             ces_at_cool.haxx.se <curl-library_at_cool.haxx.se>
                                                                        cc
                                                                           
             11/19/2008 05:34 Subject
             AM Re: connect() select() poll()
                                       checking against -1 return values
                                                                           
             Please respond to
                  libcurl
                development
             <curl-library_at_coo
                l.haxx.se>
                                                                           
                                                                           

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