Hello
I’m using ruby 1.8.0 on windows 2000. I’ve discovered that when
TCPSocket.new raises an exception, the Exception.errno variable contains
the wrong error number, and subsequently, $! contains the wrong error
text.
e.g.
TCPSocket.new(“some.host.com”, 80)
if some.host.com is not listening on port 80, you should receive error
10061: “No connection could be made because the target machine actively
refused it.” This is the error I used to receive with ruby 1.6.7
However, with ruby 1.8.0, I get error 61: "The printer queue is full"
This is obviously incorrect. It seems that 10000 has been subtracted
from the error number for some strange reason.
Cheers,
Alan.
Sorry, I managed to hit ctrl+enter before I’d finished typing this.
I meant to say, I have posted this bug before but no-one replied so I’m
hoping someone will pick it up this time.
In article MPG.19b58d98813e9b1989689@news.datastream.com,
NOSPAMcs96and@yahoo.co.ukNOSPAM says…
···
Hello
I’m using ruby 1.8.0 on windows 2000. I’ve discovered that when
TCPSocket.new raises an exception, the Exception.errno variable contains
the wrong error number, and subsequently, $! contains the wrong error
text.
e.g.
TCPSocket.new(“some.host.com”, 80)
if some.host.com is not listening on port 80, you should receive error
10061: “No connection could be made because the target machine actively
refused it.” This is the error I used to receive with ruby 1.6.7
However, with ruby 1.8.0, I get error 61: “The printer queue is full”
This is obviously incorrect. It seems that 10000 has been subtracted
from the error number for some strange reason.
Cheers,
Alan.
However, with ruby 1.8.0, I get error 61: “The printer queue is full”
This is obviously incorrect. It seems that 10000 has been subtracted
from the error number for some strange reason.
That’s not stange at all, but very well documented.
If I recall correctly from way back when I was programming
at C level under 16-bits windows, the winsock API tries to
use error codes similar to the BSD ones, except it adds this
10000 offset.
from “winsok.h”:
/*
- All Windows Sockets error constants are biased by WSABASEERR from
- the “normal”
*/
#define WSABASEERR 10000
…
#define WSAECONNREFUSED (WSABASEERR+61)
I suppose the C module which implements socket support
for ruby subtracts 10000, so that (literal) error codes
are the same under unix and windows. Unfortunately, this
code rather than the original one is also fed to the routine
which converts windows API error codes to plain messages,
resulting in the nonsense you’re seeing.
Indeed, looking at win32.c (from ruby 1.8.0):
errno = WSAGetLastError() - WSABASEERR;
repeated every time a winsock call fails. This is numerically
reasonable, but also explains the incorrect error message.
Maybe plain strerror() from the C stdlib is used to get the
error string, but under windows where (native) file handles
and sockets are not completely unified, this fails.
I am afraid a clean solution - as opposed to a kludgy workaround -
will require a bit of C surgery.
Hoping this makes things clearer,
Bernard.
PS: one thing I’d be curious to know: was the error message
actually correct under older ruby releases?
Just thought I’d throw in my $0.02 on this… I’ve seen this problem as
well, but I’ve just been ignoring it. It would be REALLY, REALLY nice if it
was fixed, though.
Nathaniel
<:((><
···
Alan Davies [mailto:NOSPAMcs96and@yahoo.co.ukNOSPAM] wrote:
I meant to say, I have posted this bug before but no-one replied so I’m
hoping someone will pick it up this time.
In article 3f4bbde9$0$1127$6c56d894@feed0.news.be.easynet.net,
bdelmee@advalvas.REMOVEME.be says…
PS: one thing I’d be curious to know: was the error message
actually correct under older ruby releases?
It used to work fine in ruby 1.6.7
In article 1061945224.656411.4014.nullmailer@picachu.netlab.jp,
matz@ruby-lang.org says…
Usa, the win32 maintainer told me he committed fix last night to the
latest CVS. Can you confirm?
matz.
When is ruby 1.8.1 coming out then?