Re: Anybody know where to find this information?
Re: Anybody know where to find this information?
- Subject: Re: Anybody know where to find this information?
- From: Quinn <email@hidden>
- Date: Thu, 29 Apr 2004 11:55:30 +0100
At 9:51 -0700 28/4/04, Dakidd wrote:
That comment is *WRONG*. What comes back in the "reason" field of my
TDiscon struct is the raw 61, not the "translated" version.
Actually, it's correct. The statement is written in the context of
the OSStatus error kECONNREFUSEDErr. It says that the positive
version of that error is what you get in the TDiscon.reason field.
To understand what's going on you have to understand a little about
OT's history. OT (on traditional Mac OS) is a Macintosh wrapper
around a UNIX STREAMS core (which we licensed from Mentat). That
core works entirely in terms of UNIX errno-style error codes, that
is, small positive numbers whose names begin with "E".
When Apple wrapped this kernel with Mac-specific libraries to form
OT, the engineer responsible decided to introduce a mapping from
these error codes into the Mac OSStatus error code range (negative
numbers). This mapping is done by two macros.
#define E2OSStatus(x) (-3199 - (x))
#define OSStatus2E(x) ((OTUnixErr)(-3199 - (x)))
E2OSStatus maps a UNIX errno style error to an OSStatus, and
OSStatus2E goes the other way. If you do the maths your find that
E2OSStatus(ECONNREFUSED) == kECONNREFUSEDErr and that
OSStatus2E(kECONNREFUSEDErr) == ECONNREFUSED.
Things got a little more complex when we decided to provide OT
compatibility on Mac OS X. Mac OS X has its own set of UNIX
errno-style error codes. You can read through the list in
"/usr/include/sys/errno.h". The problem is that these definitions
are *different* from the ones used by traditional Mac OS. And we
couldn't change the values used in the OT headers because you have to
be able to build a single Carbon application that runs on both Mac OS
9 and Mac OS X.
To solve this problem we introduced a new set of error constants in
the OT header. These are exactly like the UNIX errno-style error
codes, except that they have a "k" at the front. For example,
ECONNREFUSED is now kECONNREFUSED. This prevents them from clashing
with the <errno.h> definitions. If you don't include the <errno.h>
definitions (either because you don't care about Mac OS X or because
you're careful to avoid that header), you can define the OTUNIXERRORS
compile time variable to get back access to the OT errno-style
definitions.
Excuse me while I go off on a minor rant for a moment...
That's a /minor/ rant? Gosh, I'd hate to see a major one (-:
"Inside Macintosh: Networking with Open Transport" version 1.3
That would be the one I'm working with, I'm pretty sure.
Good.
S+E
--
Quinn "The Eskimo!" <
http://www.apple.com/developer/>
Apple Developer Technical Support * Networking, Communications, Hardware
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.