_NTO_CHF_DISCONNECT

Hi,

could anybody explain me this situation:

2 processes

[1st]. server does:
chid = ChannelCreate(_NTO_CHF_DISCONNECT);

[2nd]: client does:
coid1 = ConnectAttach (0, server_pid, server_chid, _NTO_SIDE_CHANNEL, 0);
coid2 = ConnectAttach (0, server_pid, server_chid, _NTO_SIDE_CHANNEL, 0);
MsgSend (coid2, &msg, sizeof msg, 0,0);
MsgSend (coid1, &msg, sizeof msg, 0,0);
ConnectDetach (coid1);
ConnectDetach (coid0);

Question1 is:
the only single!!! _PULSE_CODE_DISCONNECT pulse receives server!!!
why???
and why is this pulse is from last client coid which did MsgSend
ie in above example – pulse value will be coid1
but if:
MsgSend (coid1, &msg, sizeof msg, 0,0);
MsgSend (coid2, &msg, sizeof msg, 0,0);
ConnectDetach (coid1);
ConnectDetach (coid0);
then pulse value will be coid0
WHY???

Q2:
what need i do to do the following:
server will recevie _PULSE_CODE_DISCONNECT from all datached connection?


Thanks
vasilii

vasilii <vv40in@rambler.ru> wrote:

Hi,

could anybody explain me this situation:

2 processes

[1st]. server does:
chid = ChannelCreate(_NTO_CHF_DISCONNECT);

[2nd]: client does:
coid1 = ConnectAttach (0, server_pid, server_chid, _NTO_SIDE_CHANNEL, 0);
coid2 = ConnectAttach (0, server_pid, server_chid, _NTO_SIDE_CHANNEL, 0);
MsgSend (coid2, &msg, sizeof msg, 0,0);
MsgSend (coid1, &msg, sizeof msg, 0,0);
ConnectDetach (coid1);
ConnectDetach (coid0);

Um…coid1 & coid2 on connect, then coid1 & coid0 on detach? I assume
you typed something wrong there…

Question1 is:
the only single!!! _PULSE_CODE_DISCONNECT pulse receives server!!!

Yes.

why???

That is how it is supposed to behave. It is a client-disconnect message,
not a coid disconnect message. It says that the client (i.e. process,
i.e. unique nd & pid combination) is no longer talking to your server.

On the server side, you have a scoid – this (essentially) maps to a
nd & pid combination on the client side (or, if you’re single node,
you can think of it as mapping to client’s pid).

and why is this pulse is from last client coid which did MsgSend
ie in above example – pulse value will be coid1
but if:
MsgSend (coid1, &msg, sizeof msg, 0,0);
MsgSend (coid2, &msg, sizeof msg, 0,0);
ConnectDetach (coid1);
ConnectDetach (coid0);
then pulse value will be coid0

WHY???

If you check the docs for ChannelCreate(), you will see:

Pulse code: _PULSE_CODE_DISCONNECT
Pulse value: None

That is, the pulse value is not specified for this type of pulse/notification.
If you happen to see a value that matches something, well, that is just
coincidence. Don’t depend on it having any meaning, or ascribe any
particular meaning to it.

If you read further, you will see that with this pulse you must look at
the _msg_info structure associated with it when you called MsgReceive(),
and must do a ConnectDetach(info.scoid) – this scoid is the important
piece of information, telling you which client went away, not the value
in the pulse. (note that info.pid will give you the client’s pid).

Q2:
what need i do to do the following:
server will recevie _PULSE_CODE_DISCONNECT from all datached connection?

You can’t do this.

But, if you write a resource manager, you will get IO_CLOSE messages
for all fds that the client has opened to you as they close. So, you
can get per connection (fd) notification for file descriptors, but not
for side channel connections.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.