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.
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);