cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: <Jeff_Curley_at_playstation.sony.com>
Date: Tue, 18 Nov 2008 15:10:12 -0800

just a small update, I figured out why my sys_net_errno() (the Cell OS
equivalent to GetLastError) was not functioning correctly.

On CellOS there are 2 types of "error" values.
Functions like connect() return
SYS_NET_ERROR_EINPROGRESS

which is a negative number (not -1), while sys_net_errno() returns
SYS_NET_EINPROGRESS

which is something more sane like "36", so I was able to clean up my change
to
#ifdef SN_TARGET_PS3
  if( rc < 0 )
        rc = -1;
#endif

and change my code to make use of the values returned from sys_net_errno
using the setup_once.h change:
#ifdef USE_WINSOCK
#define SOCKERRNO ((int)WSAGetLastError())
#define SET_SOCKERRNO(x) (WSASetLastError((int)(x)))
#elif defined SN_TARGET_PS3
#define SOCKERRNO (sys_net_errno)
#define SET_SOCKERRNO(x) (errno = (x))
#else
#define SOCKERRNO (errno)
#define SET_SOCKERRNO(x) (errno = (x))
#endif

but sadly I've had to do this anywhere that socket functions were
explicitly checking against the value "-1", (connect, select, poll, etc..)

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. But this would force everyone who uses the
library to #define their complete implementations of socket functionality,
or at least libcurl would have to include a "base level" mapping for the
functionality which seems like too much work to support a single platform,
esp since it's such a small percentage of usage.

But the good news is, it works on PS3 with minimal changes, which is a
testament to this communities hard work. My next task is to look at the
memory manager overloading. :)

Thanks for all the replies!

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

                                                                           
             Jeff
             Curley/SDPD/SCEA@
             Playstation To
             Sent by: libcurl development
             curl-library-boun <curl-library_at_cool.haxx.se>
             ces_at_cool.haxx.se cc
                                                                           
                                                                   Subject
             11/18/2008 11:52 Re: ioctl includes missing #ifdefs
             AM
                                                                           
                                                                           
             Please respond to
                  libcurl
                development
             <curl-library_at_coo
                l.haxx.se>
                                                                           
                                                                           
Received on 2008-11-19