Re: OT Notifier
Re: OT Notifier
- Subject: Re: OT Notifier
- From: Jens Bauer <email@hidden>
- Date: Thu, 21 Feb 2002 12:13:27 +0100
Hi Michael,
The prototype looks like:
EXTERN_API( OSStatus )
OTAsyncOpenEndpointInContext(
OTConfigurationRef config,
OTOpenFlags oflag,
TEndpointInfo * info, /* can be NULL */
OTNotifyUPP upp,
void * contextPtr,
OTClientContextPtr clientContext); /* can be NULL */
-As you call OTAsyncOpenEndpoint this way:
>
err = OTAsyncOpenEndpointInContext( OTCreateConfiguration(kTCPName), 0,
>
&info, theHandler, 0, NULL );
..you give a NULL contextPtr. This should point to a valid buffer.
You need a unique contextPtr for each endpoint you create. So if you open
20 endpoints, you should have 20 buffers containing the context information.
So before you do the OTAsyncOpenEndpointInContext, you should allocate
the context buffer to use for this endpoint.
This *could* work:
epi = (EPInfo *) malloc(sizeof(EPInfo));
err = OTAsyncOpenEndpointInContext( OTCreateConfiguration(kTCPName),
0, &info, theHandler, epi, NULL);
-But beware! -You cannot call free() from the notifier. If you need to
release this buffer from within the notifier, I will strongly recommend
you to use OTMemAlloc, or you will most likely get a crash on non-Mac OS
X platforms.
On Wed, 20 Feb, 2002, Michael Paluszek <email@hidden> wrote:
>
I'm still trying to work through the notifier problem. Given a notifier of
>
the form
>
>
static pascal void EventHandler( void* context, OTEventCode event, OTResult
>
result, void* cookie )
>
{
>
TCall mycall;
>
InetAddress caddr;
>
TEndpoint *ep;
>
OSStatus err;
>
int kSc;
>
>
// Endpoint information
>
EPInfo* epi = (EPInfo*) context;
>
>
The asynchronous handler is installed using:
>
>
OTNotifyUPP theHandler = NewOTNotifyUPP( EventHandler );
>
>
err = OTAsyncOpenEndpointInContext( OTCreateConfiguration(kTCPName), 0,
>
&info, theHandler, 0, NULL );
>
>
On MacOS 9.x cookie in EventHandler contains the endpoint. On OS X it is a
>
null pointer. I added the context input but noticed on OS 9.x that all I get
>
is a null pointer for the context. This event handler seems to follow the
>
documentation and the many pieces of OT sample code (including
>
OTVirtualServer.)
>
>
Basically, I have several controllers communicating with the simulation
>
(which is simulating several processes). I need to know which endpoint is
>
incoming so that I can send the data to the correct process.
>
>
Does anyone have a suggestion of what I might be doing incorrectly?
Love,
Jens
--
Jens Bauer, Faster Software.
_______________________________________________
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: | |
| >OT Notifier (From: Michael Paluszek <email@hidden>) |