Regarding TCP connections, can someone explain the difference between Error 62 (Connection Aborted) and Error 66 (Connection Closed)?
My GUESS is that 66 means this Conn ID was closed normally via program operation and 62 means some unexpected breakage occurred (wire cut, power loss, etc).
Is that a correct guess?
If so, then 66 could only occur if I try to use a ConnID after I have closed it.
Error 63(Connection refused) means that an attempt to connect was refused by the other end, and so it could only occur on a TCP CONNECT operation, correct?
Error 64 (Not Connected) - where could that happen? If I pass NIL for CONN ID, it should report Error 1(BAD PARAMETER), if I pass a once-valid-but-now-closed ConnID, I would expect Error 66 (Connection Closed), if I pass a random ConnID number, I would expect Error 1. So when does 64 happen?
Thanks for pointers to docs, or other insights.
This knowledgebase entry might shed some light on why/when error 66 occurs...
You may be oversimplifying. Either end of a connection can close the connection, so you could get error 66 if the remote side closes the connection cleanly even if your code has not yet done so. Some of those errors may occur with UDP but not TCP. You could consult the full list of Windows Sockets Error Codes, which has a slightly more detailed list of errors and explanations, although those codes may not map directly to the LabVIEW ones. The explanation for "Not Connected" says, "
A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using sendto) no address was supplied. Any other type of operation might also return this error—for example, setsockopt setting SO_KEEPALIVE if the connection has been reset."
Either end of a connection can close the connection, so you could get error 66 if the remote side closes the connection cleanly even if your code has not yet done so.
OK, I plan to close my end on any error 62, 63, 64, 66.
But if error 66 means "somebody, on one end or the other, closed this connection", does 62 mean "wire broke, power fail, etc". ?
I'm guessing (I don't know the innards) that when you close the connection programmatically, a signal is sent down the line to the other end "Hey, I'm closing this, goodbye", and hangs up, leading to error 66 if you try something else on that ConnID.
But if somebody just pulls the plug out, there is no such handshake, and you get Error 62.
Is that a fair guess?
The reason for various error codes is not as well-defined as you'd like. See, for example, "Error 62 and Error 66 in the TCP Examples under Windows NT," "The NT OS will return error 62 or 66, depending on the state of the TCP connection when the next write call is made."
OK, so the full definition of 66 is "Closed by the PEER (the other end)".
Though it looks like I can't reliably determine whether the other end closed the connection politely, or somebody pulled the plug.