John M McIntosh wrote:
I'll be the first to say this is all a bit ill defined. You really need to check the C source code for the socket support code to understand what is happening. For os-x on or after the carbon VM 3.5.1b2 we switched to the Unix BSD socket code. The socketError primitive returns the results of capturing errno, or getsockopt(s, SOL_SOCKET, SO_ERROR, (void *)&error, &errsz) depending on what is happening at the time.
That's great even though I've thought that BSD socket's API is unified on error codes. Right now, there's no way to tell if outgoing connection to remote host failed because of network error such as connection refused, no route to host, network unreachable, etc. or because there was real timeout while connecting.
This all assumes us VM folks capture the error data and don't have multiple calls trashing things (accept processing comes to mind).
I didn't quite get that. Multiple calls inside VM or transitions in interpreting primitive calls?
Really one needs to review the C source code for the called primitive at the time of the error is required to understand where the data comes from.
On the other hand, sticking some documentation in the Socket>>socketError could be useful.
Question is, if this method could be used for error handling at all. I can imagine there would be another socket state (Socket class>>initialize) something like "Failed" which would indicate an error condition. Then #socketError could identify problem by some code - but we would need to settle on something crossplatform.
in errno.h we find #define ECONNREFUSED 61 /* Connection refused */ That seems like a reasonable error, base on the fact we see that errno when the connection request fails.
FYI pre VM 3.5.1b2 the Open Transport code would return either
kENOTCONNErr = -3256, /* Socket is not connected */ or one of another 74 numbers from MacErrors.h I'd think you would get kECONNREFUSEDErr = -3260, /* Connection refused */
On Linux I found in asm-generic/errno.h: #define ECONNREFUSED 111 /* Connection refused */
so it is different everywhere...
I see that the window source which btw now has the three semaphore support (Yah...)
Dated: * RCSID: $Id: sqWin32NewNet.c,v 1.9 2004/01/19 22:25:51 andreasraab Exp $
It calls WSAGetLastError() from time to time to collect the error information. However I suspect you'll need to confirm which windows VM you are using, then backtrack to the source code to see if having zero is the expected results....
3.6.2 as found in distribution ftp://st.cs.uiuc.edu/Smalltalk/Squeak/3.6/win/ and I assume it is one published on http://sourceforge.net/projects/squeak/ which seems to have sqWin32NewNet.c in version 1.7 - I'll try to build windows VM from CVS source.