please send a unified diff.

    i'll look at integrating your changes then!

    tc

On Sat, Dec 08, 2001 at 08:20:56PM -0500, benjamin yates wrote:
> 
>   hey all... i've been using the sockets extension pretty extensively for
> the past couple months, and it has some real problems.  obviously the best
> reason for it is the ability to use non-blocking sockets in php, which is
> great for writing simple tcpip clients and services.  i've done this with a
> set of state-machines and it works very well.
> 
>   i had to change the code alot though before i could make it all work,
> because of two issues.
> 
>   first, the library tracks socket errors with 'errno' which isn't proper on
> win32, where you must use WSAGetLastError() instead.  that's a simple fix...
> 
>   the second has more changes.  currently, the library stores the last error
> only when socket calls return "error"-ish values.  which is a problem
> because the return value of the sockets calls is not what is returned to the
> php script.  this doesn't provide enough data for writing an app that uses
> non-blocking sockets.
> 
>   example... socket_read() returns false if it didn't read anything.
> 
>     recv() returns the number of bytes read OR zero of the connection was
> closed OR -1 if another error is in errno/WSAGetLastError.
> 
>   since socket_read only returns good or bad, you can't tell the specific
> error without the socket_last_error being correct...
> 
>   i hope this makes sense to someone.  the last time i built this and
> patched it, i sent my changes from (at the time) the current CVS to the
> authors in the sockets.c but never got any response - so now i'm posting it
> here.
> 
>   i repatched the latest cvs snapshot, and i just tested it out on one of my
> scripts and it's working fine for me.  i don't know if it might break some
> unix implementations - i think it will be fine.  the code isn't the best,
> because there are places where socket function calls are inside of if()'s,
> and the last error must be stored, so instead of reorganize everything, i
> just put multiple calls to my error storage macro where it was needed.  i
> don't know all the coding standards you go by so i didnt' want to spend time
> making a bunch of changes that wouldn't be wanted.
> 
>   i zipped my sockets.c and the original, taken from the latest cvs
> snapshot - it's available at
> 
>   http://www.newnetwork.com/benjamin_sockets.zip
> 
>   thanks for looking at it...
> 
>   oh and i don't know why someone decided that the socket_last_error()
> should clear the error when calling it, i can't think of any reason why...
> and it means that i have to store it before i use it in a script, if i must
> make multiple references to it.  not a big deal but i just can't come up
> with why it should be cleared.
> 
>   well perhaps someone thought it should be cleared before i decided that it
> should be set after every call :)
> 
>   -benjamin
> 
> -- 
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to