OK, I'm stumped - Why doesn't this work?
OK, I'm stumped - Why doesn't this work?
- Subject: OK, I'm stumped - Why doesn't this work?
- From: Dakidd <email@hidden>
- Date: Tue, 9 Nov 2004 11:18:04 -0800
Somehow, I'm getting the feeling I've missed something that's stupidly
simple, but I'm not managing to figure out what it is. I need a "no-frills"
routine to grab the IP address of the machine that my code is running on -
Assuming it has one, is connected, and all the other "etc" that goes with
working with OT.
The "most likely suspect" looks to be calling OTInetGetInterfaceInfo(),
then snatching the "fAddress" field of the returned InetInterfaceInfo
struct, converting it to the form I need, and returning that. But it just
doesn't happen that way, and I can't see any explanation for why regardless
of where I look.
As can be seen by looking at the code, I'm writing for OT. (WIthout going
and looking, I'm pretty sure it's OT 1.6 on my development machine - I'd
have to go digging to find out precisely which version I'm currently
running) What can't be seen is that I'm targeting MacOS 9.1, using the last
known (to me) version of Universal headers/interfaces, under CodeWarrior 5.
I have no problems with "canned" internet software - Everything "just
works". But not my "roll your own" code...
The problem bites me regardless of whether the connection is up or not.
Somebody tell me I've just overlooked something??? Or is this only a
symptom of a deeper problem?
OTInited is declared globally -
int OTInited;
ReportAndDie() does exactly what its name suggests, and works precisely as
expected.
Here's the actual routine that's doing a good job of driving me bonkers:
void GetMyIPNumber(char *Storage)
{
OSStatus Error;
InetInterfaceInfo TheInfo;
SInt32 Val = kDefaultInetInterface;
// Make sure OT is alive and kicking...
if (OTInited != 1)
{
Error = InitOpenTransport();
if (Error != kOTNoError)
{
ReportAndDie(Error);
}
else
OTInited = true;
}
else // OT is ready to roll...
{
// Clear any cruft out of the return buffer.
for (Storage[0] = 1; Storage[0] < 16;Storage[0]++)
Storage[Storage[0]] = ' ';
Storage[0] = ' ';
// Ask OT what my address is.
Error = OTInetGetInterfaceInfo(&TheInfo, Val);
// Invariably, "Error" returns from the above call holding -3201.
// Looking in MacErrors.h for an explanation shows two separate
// errors that map to -3201:
// kOTNotFoundErr = -3201, /* OT generic not found error */
// kENOENTErr = -3201, /* No such file or directory */
// First problem: Which error am I actually seeing?
// Second problem: Neither one makes any sense (at least to me) in
// this context.
// Maybe you can explain it?
if (Error != kOTNoError)
{
ReportAndDie(Error);
}
else
{
OTInetHostToString(TheInfo.fAddress, &Storage[0]);
}
}
}
Hoping to hear an explanation of what I'm doing wrong...
Don Bruder - email@hidden <--- Preferred Email - unmunged
I will choose a path that's clear: I will choose Free Will! - N. Peart
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden