• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: DNR
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DNR


  • Subject: Re: DNR
  • From: Jens Bauer <email@hidden>
  • Date: Tue, 26 Feb 2002 18:39:44 +0100

Hi Pietrzak,,


On Tue, 26 Feb, 2002, Pietrzak, Bryan <email@hidden> wrote:

>I'm not a network programmer, so please forgive my ignorance here.
>
>I use NetSprocket in my games which insulates me from a lot of the
>underlying network stuff. I use an OTAddress to talk to our game server.
>Currently I'm creating the OTAddress from a specific ip address (155.183.1.1
>or something, I don't remember offhand :)

Gotta start somewhere. ;)

>However, now I'd like to instead take "hms.freeverse.com" and find out what
>IP address it resolves to and use that to get NSp going. It looks like I
>need to use OTLookupName() to do this.

OTLookupName is a good choice. :)

>But, after looking through the docs,
>it looks like there are multiple ways to do this and I'd like to make sure I
>do it the "right" way.

OTLookupName does what it says, it looks up the name.
I've never used OTInetStringToAddress myself, but the docs at..
<http://developer.apple.com/techpubs/mac/NetworkingOT/NetworkingWOT-395.html>

says:

A single host can be associated with multiple internet addresses. You can
use the OTInetStringToAddress function to return multiple addresses for
multihomed hosts.

Reading a bit further gives you this information:

The OTLookupName function provides a mapper interface to the domain name
resolver (DNR) that maps a name to a single internet address.

-So the difference seems to be that OTLookupName returns one address,
while OTInetStringToAddress returns one or more IP addresses.

>Is there any sample code on doing this, or is this so basic that no one
>would really even ask and I'm just showing my ignorance here :)

Definately. You should have a look at Apple's FTP-server:

ftp://ftp.apple.com/developer/Sample_Code/

In the folder "Networking" you will find a bunch of good network sample
code from simple to advanced.

I'd like to give you a hint though. Here's a part of some code I wrote
ages ago...


ProviderRef provider;
TLookupRequest *req;
TLookupReply *reply;

// Note: You need to point the above 2 pointers to valid structures.

if(0 == configurationMaster)
{
configurationMaster = OTCreateConfiguration(kDNRName);
}
if(configurationMaster)
{
configuration = OTCloneConfiguration(configurationMaster);
provider = (ProviderRef) OTOpenMapper(configuration, 0, &err);
if(kOTInvalidProviderRef != provider && kOTNoError == err)
{
(a bunch of code is missing)
...
set up req and reply structures
OTMemzero(req, sizeof(*req));
req->name.len = OTStrLength(name);
req->name.buf = new UInt8[req->name.len];
req->addr.len = 0;
req->addr.buf = 0;
req->maxcnt = 1; // don't know if this should be 1 or 4.
req->timeout = 1000; // one sec. timeout (testing)

OTMemzero(reply, sizeof(*reply));
reply->names.buf = (unsigned char *) buf;
reply->names.maxlen = buflen;
...
err = OTLookupName((MapperRef) provider, req, reply);
}
}

Remember to do a...
OTCloseProvider(provider);

When you're finished.

You may want to make an asynchronous name lookup instead of a synchronous
lookup. The above sample is not complete, as I just made some cuts here
and there where it used non-OT calls, to simplify it.


Love,
Jens

--
Jens Bauer, Faster Software.
-Let's make the World better, shall we ?
_______________________________________________
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.

References: 
 >DNR (From: "Pietrzak, Bryan" <email@hidden>)

  • Prev by Date: Re: T_MEMORYRELEASED
  • Next by Date: Re: UDP Sockets & Clock Synchronization
  • Previous by thread: DNR
  • Next by thread: Re: UDP Sockets & Clock Synchronization
  • Index(es):
    • Date
    • Thread