Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Porting Open Transport Code. Crashing on YieldingNotifier



Hi. I've just recently started working with MacOS X (a bit late, I know)

I'm trying to port a program I wrote which uses Open Transport.
I'm creating a C++ class to handle data over a connection with a server.

If I DO NOT install a Yielding Notifier, it works fine.
But when I do install it, the program crashes when I call OTBind() before I try to connect to a server.


The crash window says it's crashing inside 'WaitForSyncDone' called from OTBind().

My code is based on nearly identical sample code from Apple: OTSimpleDownloadHTTP.

The only difference between the programs I can find is that mine is C+ + and the sample code is plain C.
I've tried using extern "C" around the yielding notifier with no success.


Any hints on what I might be missing would be greatly appreciated.


MY YIELDING NOTIFIER:

static pascal void yieldingNotifier (void *contextPtr, OTEventCode code, OTResult result, void *cookie)
{
#pragma unused(contextPtr)
#pragma unused(result)
#pragma unused(cookie)


    switch (code)
    {
        case kOTSyncIdleEvent:
            YieldToAnyThread();
            break;
        default:
            // do nothing
            break;
    }
}


THE CODE TO CONNECT TO A SERVER:

ep = OTOpenEndpointInContext(OTCreateConfiguration(kTCPName), 0, nil, &err, nil);

    // If the endpoint opens successfully...
    if (err == noErr)
    {
        // Establish the modes of operation.  This sample uses
        // sync/blocking mode, with sync idle events that yield
        // time using the Thread Manager.
        err = OTSetSynchronous(ep);

        if (err == noErr)
            err = OTSetBlocking(ep);

if (err == noErr)
err = OTInstallNotifier(ep, NewOTNotifyUPP (yieldingNotifier), nil);


        if (err == noErr)
            err = OTUseSyncIdleEvents(ep, true);

        // Bind the endpoint.  Because we're an outgoing connection,
        // we don't have to bind it to a specific address.
        if (err == noErr)
            err = OTBind(ep, NULL, NULL);

THIS IS WHERE IT CRASHES

--
email@hidden       http://www.mts.net/~gbeggs1/

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/macnetworkprog/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.