Re: Is there a clean way to get my default IP address.
Re: Is there a clean way to get my default IP address.
- Subject: Re: Is there a clean way to get my default IP address.
- From: John Draper <email@hidden>
- Date: Tue, 06 Dec 2005 14:10:44 -0800
Justin C. Walker wrote:
Hi, John,
I've mulled this over a bit more, and provide the following to help
set the stage for discussion. Please follow-up to the list.
OK - sending this to the list - no flamage please - I'm a newbie :-)
From the Mac OS X perspective, you have a default interface, not a
default IP address. That interface is the one that carries (i.e.,
provides, either by manual entry or something like DHCP) the default
route, the DNS servers, etc.
Is that like the "en0" and "en1" you see in the "ifconfig" output? Is
that what you mean by "Interface".
Since a system like a Mac can have several active interfaces, these
are ordered (by the user, e.g., using the network control panel) to
provide priority: the highest priority interface at any given time is
that one that is both active and highest in the priority order.
Yes - It would be nice for me to figure out how to find them under
program control. But I'm going to
have to spend at least 3 months to learn them. I don't even know where
to start. The URL references
you gave me, is something I'm going to have to read over and over to
comprehend it.
To each interface there can be assigned multiple IP addresses.
Multiple ones? WOW!!! yet MORE confusion... Gackkkk!
These can come and go, and there is no good way to choose a default
among them. That's why I say there is no default address on Mac OS X
(and therefore, no way to talk about, or retrieve, "my" or "the" IP
address).
Hmmm - So how does "ifconfig" get this information? If I do an
"ifconfig -a" I get a list of
all the devices, and some are "active" and others are not. What code
or API gets this information?
Is it calls to "gethostbyname" and looking at the hostent it returns?
Or is there some other
lower level device level means it uses to get me the "inet" value of a
device (en0, or en1).
I know from experience, I can have BOTH a wired connection and a WIFI
connection if I turn
on my airport. Then, as I do the "ifconfig" I see both active, but
they have different IP
addresses. But only the "active" ones do. I presume only ONE is
designated as the one to
use for outgoing connections? My what criteria is that one selected?
From the Network
Control panel? You say I can access this info under program control?
Where can I find
some example code to do this.... does it exist? I looked at the URL's
you gave me earlier,
but in looking at the code, and the function API names that were used,
I could not make
an association to one that would return my IP address (the high priority
one).
So what API's are appropriate to use if I want to access internal data
used by the "ifconfig".
or better yet, use the data they display in the Mac's Network control
panal?
The reason you aren't seeing any clear way to get the default IP
address is that the concept is not present in anything that Mac OS X
provides.
Yes - I see that...
I gather you are trying to port an app, is that correct?
Yes - from the WinBlows to the Mac... and when one has an airport
connected as well as an
ethernet connection, I'm afraid my code will break.
It could be that the problem you are having is that the view taken by
Mac OS X doesn't match that of the system where this code originally
ran.
The "view" is standard UNIX socket code. Isn't the Carbon SFSocket
calls built on top of the
UNIX socket code?
I'm porting a UNIX library to the Mac. "resipricate". I have it
working. But as I explained
in the private message, I was confused because of the inconsistancies of
how UNIX sockets
passes pointers. Some I have to allocate, others I dont. I just
couldn't possibly know in
advance on which is which. A good source of UNIX socket programming is
an older book,
"Unix socket programming" but (sigh) it's out of print.
http://beej.us/guide/bgnet/output/html/index.html
Best source for docs on UNIX sockets I found... take note guys - this
is a good source.
If I understand this correctly, can you give me a succinct statement
of the high-level goal you are shooting for (not to mix metaphors too
badly)?
Porting a WinBlows SIP phone to the Mac. Overall goal.... and it's NOT
as easy as one would think.
I mean - lets look at the facts... as of now, there is only ONE native
application running on the Mac
(Gizmo). Unfortunatly is it only usable with their SIP server, and no
source available, so cannot
embed it into other Apps.
There is also X-Lite from X-Ten. It's originally designed for windows
and Linux. Source not
available, it uses wxwindows portable GUI and the Linux portable Sound
library, that has layer
on layer of conversion code, adding a whopping overhead on processing,
making it all but impossible
to get anything better then 150 ms latancy. I already developed a non
sip one, using proprietary
network protocol, and it was using the Notification manager for sound
processing and it has
about 90 ms latency, very SOLID audio using the GSM codec (which I got
from a posting about
12 years ago - published by Jutta). WOW - It sounded heaps better then
X-Lite... now want
to use it with an RTP stack. Considering using QT, but licensing
issues with the corp guys at
the top of the feed chain want me to consider using alternate means...
Considering using
JRTPLIB for the RTP stack... unless Apple can release one that don't
require QT.
Considering using the code from...
http://developer.apple.com/darwin/projects/streaming/
Not sure if I can do it or not, but to list member here, "do you have
any ideas
on this" - feedback always welcome... want to use the RTP and Media
transport
and interface with Mac Core Audio. May be out of context of this list, but
there IS network code involved...
Heck, according to shark - I'm using only 25% CPU for the sound part... on
my mac...
Machine Model: PowerBook
CPU Type: PowerPC 750 (83.0)
Number Of CPUs: 1
CPU Speed: 500 MHz
L2 Cache (per CPU): 1 MB
Memory: 512 MB
Bus Speed: 100 MHz
Boot ROM Version: 3.2.7f2
Which isn't that bad, as you see, its rather puny when compared to
today's Macs.
But - to anyone on this list, can someone recommend the best RTP
and Media transport API's I can use for this project. I have the
SIP part finally working.... resipricate seems to be the one of my
choice, lacking anything from Apple. sipx, another open source
SIP stack is virtually impossible to port to the Mac, It has
So many dependencies to Linux only libraries...
Regards
John
_______________________________________________
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