-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
if (! connect(...)) { handle error } #63
Comments
i think is ok like is writen!
in man of connect https://man7.org/linux/man-pages/man2/connect.2.html.
in c language (https://c-for-dummies.com/blog/?p=1188)
this if condition try to check if connect is ko...
if need to bee changed, the prefered condition while be
|
Hello Mathieu - I beg to differ |
no |
.. and yes, changing the test to "the preferred condition while be != 0", will work too. Note that (connect() != 0) is different than (!connect()). |
is equivalent, but more readable. |
Not equivalent. Different. (!connect()) is equivalent to (connect() == 0) |
no i not ok with that!
in c language, 0 = false and not 0 is true.... |
No. it is not working. This is how I noticed it. |
is used in many project.... if the condition not worked any project on unix using this framework while not work at all... |
[Ovidiu has revised this post, to match the mcarbonneaux post above. After the edits, the 2 posts are now in agreement] |
then |
This happens on Windows, not unix. |
"0 is false in c langage" . Yes. (!connect()) --> false --> 0 --> and man says that 0 is the return value for success, but the Windows if(!connect()) executes the failure branch, in case of success |
are you sure that connect on windows return 0 on success ? because this function is the first function that are call when you use this framework... i'm suprise that not work on windows... on unix part is checking differently.
on windows the connect fonction seem to work like on unix:
but the check are not the same (i ok with you but i don't understand why none as send feedback for that):
but is possible that the most used case on windows is using pipe.... |
i sayed erronous: the if condition try to check if connect is ko... when connect return -1 in ko case:
when connect return 0 in ok case:
and simple (connect()) or (connect()!=0) or (connect()<0) (like you sayed) while be ok. |
Bingo! - Yes, connect() in Windows works the same as in unix (it returns 0 for success and -1 for error). |
Hello, It seems to me that the statement in https://github.com/FastCGI-Archives/fcgi2/blob/master/libfcgi/os_win32.c, function int OS_FcgiConnect(char *bindPath), line 850 should be changed to:
if (connect(sock, (struct sockaddr *) &sockAddr, sockLen) < 0) { ...
Best regards,
Ovidiu Adam
The text was updated successfully, but these errors were encountered: