Re: Using dead notification with mach ports
Re: Using dead notification with mach ports
- Subject: Re: Using dead notification with mach ports
- From: Stéphane LETZ <email@hidden>
- Date: Sat, 11 Sep 2004 10:55:23 +0200
>> 4) client get this new private port from the server (same method as 2
>> )
>
> This is where you went astray. The clients wouldn't look the new
> message queue up in some global namespace, but instead it would be
> returned to them (privately) as part of the reply to this "connection
> request" RPC.
>
>>
So now the server does the following fo each new client in the
"connection request" RPC.
mach_port_t task = mach_task_self();
mach_port_t old_port;
mach_port_allocate(task,MACH_PORT_RIGHT_RECEIVE,&clientPort)
mach_port_insert_right(task,clientPort,clientPort,MACH_MSG_TYPE_MAKE_SEN
D)
mach_port_move_member(task,clientPort,serverPort)
mach_port_request_notification(task, clientPort,
MACH_NOTIFY_NO_SENDERS,
1, serverPort,
MACH_MSG_TYPE_MAKE_SEND_ONCE,&old_port);
where serverPort will be used by the server in the mach_msg_server.
Then clientPort has to be sent back to the client, how is this done?
Only by sending the clientPort back? Or the client needs to get a copy
of send right to that clientPort Mach message queue alloccated by the
server?
I'm quite confused...
I am also using inter-process server/client Mach semaphores for
synchronization purpose. Right now, I was allocating the semaphore on
the server side with "semaphore_create" then registering it in the
bootstrap namespace using "bootstrap_register" with a name for each
semaphore (associated with a given client). Then the client was using
"bootstrap_look_up" to get its semaphore. This is working.
But I guess registering the semaphores in the bootstrap namespace is
not a very good idea, and since Mach semaphores are actually Mach
ports, I guess semaphores could be handled exactly like the previous
"private port" mechanism for server/client communication.
But again I don't understand how the "private port" (or semaphore)
allocated on the server side is given back to the client side in a way
the client can used them.
Thanks for any advice
Stephane Letz
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.