Professional Web Applications Themes

Need some OT (Open Transport, not Off Topic) help, please? - Mac Programming

OK, I know I'mlgging behind the curve (and probably dating myself horribly besides) but here's the deal - I'm working under 9.1, trying to write some networking code to replace GUSI in a specific application . Nothing against the author, but GUSI is just plain unstable, IMO. (or at least seems to be - nothing I can "prove" at this point, just a bunch of rather vague "this kind of thing *ONLY* happens when a program that relys on GUSI for its networking is, or has recently been, running" incidents that make up what seems like a rather suspicious pattern) ...

  1. #1

    Default Need some OT (Open Transport, not Off Topic) help, please?


    OK, I know I'mlgging behind the curve (and probably dating myself
    horribly besides) but here's the deal -

    I'm working under 9.1, trying to write some networking code to replace
    GUSI in a specific application . Nothing against the author, but GUSI is
    just plain unstable, IMO. (or at least seems to be - nothing I can
    "prove" at this point, just a bunch of rather vague "this kind of thing
    *ONLY* happens when a program that relys on GUSI for its networking is,
    or has recently been, running" incidents that make up what seems like a
    rather suspicious pattern)

    Regardless of my motivation, I'm trying to redo a progam that used GUSI
    for networking, in "full native" OpenTransport. If nothing else, it
    should be at least slightly more efficient without all the overhead GUSI
    imposes, and MAYBE it'll even cure a problem that, to date, has eluded
    all my efforts to track it down.

    The reason I used GUSI in the first place was that it was there, and I
    was lazy - trying to network from the Mac seems like an exercise in
    overkill as far as "general-purpose the interface to the point where it
    isn't usable for any specific task", and there was GUSI, all set to go.
    So I never climbed the learning curve to adopt OT.

    Time to change that.

    So the first step is figuring out how to work with OT. Got all the docs
    I can locate, and though they're pretty darn good, nicely detailed, etc.
    etc, I'm hitting a wall when I try to do a DNS query.

    What follows is the current state of the code that's giving me trouble.

    begin paste (pardon any poorly done wrapping... Honest, it's not my
    fault!)

    #include <Memory.h>
    #include "InitOT.h"
    #include "DNSLookup.h"
    #include <Stdio.h>

    extern int OTInitialized;


    struct hostent *gethostbyname(const char *Name)
    {

    OSStatus Result = kOTNoError;
    OTConfiguration *TheConfiguration;
    OSStatus QueryGood = kOTNoError;
    struct hostent *TheHostEnt;
    InetSvcRef TheReference;
    InetHostInfo TheHInfo;

    TheHostEnt = (struct hostent *)NewPtrClear(sizeof(struct hostent));
    if (TheHostEnt)
    {
    // All good... memory was allocated, can proceed.
    if (!OTInitialized)
    {
    // Hmmm... We're the first routine to use OT this run? OK...
    Fire it up.
    FireUpOT();
    }
    else
    {
    // OT is already initialized.
    }
    // Make sure that the FireUpOT call above worked if OT wasn't
    already initialized
    if (OTInitialized)
    {
    // Create a configuration doohickey. We're going to need it
    when we try to
    // do the OTOpenInternetServices() call.
    Result = CreateConfiguration(&TheConfiguration);
    // Do whatever is needed to open/setup/whatever the "provider"
    that's going to do DNS lookups.
    // Duhhhhhhhh... still not certain on the "how-to" of that.
    Gotta do some more reading...

    // Put it here when you figure it out, stupid.
    TheReference = OTOpenInternetServices(TheConfiguration, 0,
    &Result);

    if (Result == kOTNoError)
    {
    // It's all good. We can proceed

    // Make the actual query
    QueryGood = OTInetStringToAddress(TheReference,
    (char *) Name, &TheHInfo);
    if (QueryGood)
    {
    // Good to go
    // Massage the result into *nix form
    }
    else
    {
    // Query failed, for whatever reason
    printf("DNS Query failed (Result Code
    %d)\n", QueryGood);
    }
    }
    else
    {
    // Something whent wrong when trying to open the
    service
    printf("Error %d while attempting to
    OTOpenInternetServices()\n", Result);
    }
    }
    else
    {
    // unable to init OT
    printf("OT is not/could not be initialized\n");
    }
    }
    else
    {
    // Couldn't allocate memory for the result
    printf("Unable to allocate memory for hostent struct\n");
    }
    return TheHostEnt;
    }

    end paste

    So, going at it from the top down, here's what I *THINK* you probably
    need to know that isn't visible in the code itself:

    "FireUpOT()" is wrapped around the "InitOT()" routine. It does some
    version and availability checking to find out what, if any, version of
    OT is installed on the machine, issues the InitOT() call, then sets up
    the global "OTInitialized" to reflect its success or failure at getting
    OT fired up.

    Here's the CreateConfiguration call:
    OSStatus CreateConfiguration(OTConfiguration **TheResult)

    {
    OSStatus ReturnValue = 0;
    OTConfiguration *TheConfiguration;

    TheConfiguration = OTCreateConfiguration("tcp");

    if ((TheConfiguration != kOTInvalidConfigurationPtr) &&
    (TheConfiguration != kOTNoMemoryConfigurationPtr))
    {
    /* It's all good */
    ReturnValue = 0;
    }
    else
    {
    /* Signal an error */
    printf("Error in CreateConfiguration: %d\n",
    TheConfiguration);
    ReturnValue = -1;
    }
    if (ReturnValue == 0)
    *TheResult = TheConfiguration;
    else
    *TheResult = 0;
    return ReturnValue;
    }



    Pretty routine stuff to be doing, it would seem - create a
    configuration, error check the attempt, and return it. Which seems to
    work just fine.

    Where I'm hitting real trouble is in the "almost silent" way that the
    call to "OTInternetServices()" is failing. All attempts, regardless of
    conditions during the attempt, fail with a -3170 result code, which
    apparently translates to "kOTBadNameErr", which OpenTransport.h has
    commented as /* -3170 A bad endpoint name was supplied */

    Ummm... OK, a bad endpoint name... Errr... What name???? And why is it
    "bad"? And perhaps just as importantly, what endpoint??? ... Or perhaps
    "what endpoint???" is a part of the problem? As in "Nobody told us about
    an endpoint to be used, so we're gonna barf and say that you gave us a
    bad name"

    That doesn't seem to make any sense, though, since I can find no
    reference to endpoints in connection with trying to do a name lookup.

    As far as I can tell from the docs, doing a DNS query should be as
    simple as making sure InitOT has been called, a tcp configuration is
    created, and a call to OTOpenInternetServices() is done. Once that's all
    been done, calling one of the 2-3 available lookup routines (in this
    particular case, "OTInetStringToAddress") should be handing back the IP
    numbers that go with a DNS name.

    I'm apparently missing something here...

    Can anyone give me a clue what the "something" is? Nothing in the 900+
    pages worth of OT docs I have seems to apply, and I'm currently sitting
    here pretty well stumped.

    --
    Don Bruder - net <--- Preferred Email - SpamAssassinated.
    Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
    I will choose a path that's clear: I will choose Free Will! - N. Peart
    Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>
    Don Guest

  2. #2

    Default Re: Need some OT (Open Transport, not Off Topic) help, please?

    On Sun, 23 Nov 2003, Don Bruder wrote:
     

    Have you tried using the constant kDefaultInternetServicesPath
    for your configuration (it's the default one)?

    Fred
     

    Frederick Guest

  3. #3

    Default Re: Need some OT (Open Transport, not Off Topic) help, please?

    In article
    <srcf.societies.cam.ac.uk>
    ,
    Frederick Cheung <DUH.ucam.org> wrote:
     
    >
    > Have you tried using the constant kDefaultInternetServicesPath
    > for your configuration (it's the default one)?[/ref]

    Um... Nope. Until about thirty seconds ago. Not quite sure *HOW* to use
    it. Using it as the arg to OTCreateConfiguration() gives me a compile
    error. (Wants to convert it into a char * and can't)

    Hokay... THAT'S why... D'OH! Helps if I use it as the OTConfiguration *
    arg to the OTOpenInternetServices() call...



    excellent... That's helped immensely! However, I'm still left wondering
    why my original version (that creates its own OTConfiguration *) wants
    to puke. According to the "Networking With OT" docs I've got, it should
    be performing just fine. Maybe I'm just not hoding my mouth right? :)

    --
    Don Bruder - net <--- Preferred Email - SpamAssassinated.
    Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
    I will choose a path that's clear: I will choose Free Will! - N. Peart
    Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>
    Don Guest

Similar Threads

  1. I found this in a topic and thought it should be a new topic
    By Dee Holmes in forum Adobe Illustrator Macintosh
    Replies: 0
    Last Post: May 7th, 01:18 AM
  2. Timing out connections in Open Transport
    By Kaydell in forum Mac Programming
    Replies: 0
    Last Post: September 22nd, 02:36 PM
  3. TCP/IP transport error !!
    By Seb in forum Windows Networking
    Replies: 1
    Last Post: July 14th, 04:38 PM
  4. How can I use CD-RW to transport my Briefcase
    By Steve in forum Windows XP/2000/ME
    Replies: 0
    Last Post: June 30th, 06:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139