Re: [INTERNALS-WIN] noticed some incorrect error handling for some socket specific API's on windows
[email protected] (Keisial)
| Newsgroups | php.internals.win |
|---|---|
| Message-ID | <[email protected]> |
Sriram Natarajan wrote: > HI > On Windows , socket API's does not return '-1' on failure. In this > case, most commonly returned error code is either SOCKET_ERROR or > INVALID_SOCKET. Af course, most of us know this. However, I did notice > that within our php implementation in some places we do check for the > same BSD style error value (< 0) rather than using the appropriate > macros. Both SOCKET_ERROR and INVALID_SOCKET value -1. So the current code isn't wrong. > Here is a suggested patch to address this. Here, the issue is - if we > didn't catch the error at the right place, we might end up providing > incorrect error message(s). Please let me know, if I overlooked some > thing obvious here. You are checking the getsockname() return against SOCK_CONN_ERR. However, msdn documentation on getsockname function specifies "If no error occurs, *getsockname* returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling *WSAGetLastError* <http://msdn.microsoft.com/en-us/library/ms741580%28VS.85%29.aspx>." http://msdn.microsoft.com/en-us/library/ms738543%28VS.85%29.aspx Finally, I don't have SOCK_CONN_ERR on my windows headers, although I checked on several versions. It may be a new macro also evaluating to -1, but I wouldn't use a macro so hard to have.