Euphoria
Ticket #602:
sockets:socket documentation
-
Reported by
Mihail121
Feb 06, 2011
The documentation states that this function should return -1 on failure. In fact, the function returns -38 and assigning this value to connectionSocket causes a type-check failure:
include std/socket.e
socket connectionSocket = sockets::create(AF_INET, SOCK_STREAM*50, 0)
Please correct documentation or function.
Details
1. Comment by jimcbrown
Feb 06, 2011
At one point in time, create() returns -1 on error and then there was a separate function to get the actual error code. Just like getting errno or calling GetLastError() in W32API.
This was scrapped and never became part of a release. Instead, the error code is now returned directly by the function that reports it.
I believe that the function is correct, but the documentation was simply never update.
I also have to backtrack from the type check error. The socket type will only validate valid sockets. Socket errors thus fail, and when you assign one to a variable of type socket you get a type check error.
This is a fail-early philosophy. (If your code isn't properly detecting and handling these errors, better to fail now than silently ignore the error and cause things to go awry later.) I might not like it, but that philosophy is a big part of Euphoria 4.0's current design.
2. Comment by SDPringle
Jun 30, 2011
Rather than finding bugs that don't match the documentation, we look at the code and then check to make sure the documentation is in agreement with it. We change the docs to fit the code. I may not like this, but this is the way the work flow operates.
3. Comment by SDPringle
Jul 01, 2011
fixed in change-set c0a2e1f94515