Flags in ChannelCreate()

The document about the flag _NTO_CHF_COID_DISCONNECT is
not very clear. When I turned to Robert Krten’s book, the description
about this flag also made me confused.

Who could explain this flag in an easy-to-understand way, an example
would be very useful.
Assume process A calls ChannelCreate() with this flag set, process B
connects
this channel by calling ConnectAttach().

What is the difference between two cases (with and without this flag)?
Thanks.

Jerry <xwindow@yahoo.com> wrote in message news:b0i594$g16$1@inn.qnx.com

The document about the flag _NTO_CHF_COID_DISCONNECT is
not very clear. When I turned to Robert Krten’s book, the description
about this flag also made me confused.

Who could explain this flag in an easy-to-understand way, an example
would be very useful.
Assume process A calls ChannelCreate() with this flag set, process B
connects
this channel by calling ConnectAttach().

What is the difference between two cases (with and without this flag)?
Thanks.

When B calles ConnectAttach(), it got back a “connection id”. Actually,
a “server side connection id” (scoid) also created in Process A to identify
the same connection.

Without the flag, if B ConnectDetach(coid), or crashed, or being killed
by some sort of signal, A will never know, and have the scoid opened.

With the flag, anytime B gone, A got nitified (with a pulse, and scoid in
pulse), A could then call ConnectDetach(scoid) to free the scoid.

-xtang

“Xiaodan Tang” <xtang@qnx.com> wrote in message
news:b0ib13$ec9$1@nntp.qnx.com

Jerry <> xwindow@yahoo.com> > wrote in message
news:b0i594$g16$> 1@inn.qnx.com> …
The document about the flag _NTO_CHF_COID_DISCONNECT is
not very clear. When I turned to Robert Krten’s book, the description
about this flag also made me confused.

Who could explain this flag in an easy-to-understand way, an example
would be very useful.
Assume process A calls ChannelCreate() with this flag set, process B
connects
this channel by calling ConnectAttach().

What is the difference between two cases (with and without this flag)?
Thanks.

When B calles ConnectAttach(), it got back a “connection id”. Actually,
a “server side connection id” (scoid) also created in Process A to
identify
the same connection.

Without the flag, if B ConnectDetach(coid), or crashed, or being killed
by some sort of signal, A will never know, and have the scoid opened.

With the flag, anytime B gone, A got nitified (with a pulse, and scoid in
pulse), A could then call ConnectDetach(scoid) to free the scoid.

-xtang


I thought the flag _NTO_CHF_DISCONNECT does what you said.

then what is difference between _NTO_CHF_DISCONNECT and
_NTO_CHF_COID_DISCONNECT?

Appreciate your help.

Jerry <xwindow@yahoo.com> wrote in message news:b0iasq$lu3$1@inn.qnx.com

“Xiaodan Tang” <> xtang@qnx.com> > wrote in message
news:b0ib13$ec9$> 1@nntp.qnx.com> …

Jerry <> xwindow@yahoo.com> > wrote in message
news:b0i594$g16$> 1@inn.qnx.com> …
The document about the flag _NTO_CHF_COID_DISCONNECT is
not very clear. When I turned to Robert Krten’s book, the description
about this flag also made me confused.

Who could explain this flag in an easy-to-understand way, an example
would be very useful.
Assume process A calls ChannelCreate() with this flag set, process B
connects
this channel by calling ConnectAttach().

What is the difference between two cases (with and without this flag)?
Thanks.

When B calles ConnectAttach(), it got back a “connection id”. Actually,
a “server side connection id” (scoid) also created in Process A to
identify
the same connection.

Without the flag, if B ConnectDetach(coid), or crashed, or being killed
by some sort of signal, A will never know, and have the scoid opened.

With the flag, anytime B gone, A got nitified (with a pulse, and scoid
in
pulse), A could then call ConnectDetach(scoid) to free the scoid.

-xtang


I thought the flag _NTO_CHF_DISCONNECT does what you said.
then what is difference between _NTO_CHF_DISCONNECT and
_NTO_CHF_COID_DISCONNECT?

Oops. Sorry for that. the _NTO_CHF_COID_DISCONNECT is the
otherway arround. Let’s try it again.

A ChannelCreate() and B ConnectAttach() to it, what happens if A
crashed, or it simply called ChannelDestroy() ? B wouldn’t get informed.
(B could call MsgSend() and try to hit a ESRCH or EBADF, but
that’s not for sure.)

What B would do is, it will ChannelCreate(_NTO_CHF_COID_DISCONNECT)
(note only one channel in a process allowed to set this flag). B will then
have a thread MsgReceive() on the channel to get the notification
that A is died…

Does this make sense now ?

-xtang

Great, right now everything is clear!. Thanks a lot.

Another question if you don’t mind.
the flag bit _NTO_MI_UNBLOCK_REG in MsgInfo will be set if the client
wishes to unblock.
I just don’t understand the the significance of this flag because
when I use _NTO_CHF_UNBLOCK in ChannelCreate(), the server will
receive a notification from the kernel indicating the client wishes to
unblock (thus
the thread in the server can set an internal flag itself to achive the same
goal).
So it seems that this flag (_NTO_MI_UNBLOCK_REG) is not necessary.
Does it have any special meaning or special use?







“Xiaodan Tang” <xtang@qnx.com> wrote in message
news:b0ichu$fa1$1@nntp.qnx.com

Jerry <> xwindow@yahoo.com> > wrote in message
news:b0iasq$lu3$> 1@inn.qnx.com> …

“Xiaodan Tang” <> xtang@qnx.com> > wrote in message
news:b0ib13$ec9$> 1@nntp.qnx.com> …

Jerry <> xwindow@yahoo.com> > wrote in message
news:b0i594$g16$> 1@inn.qnx.com> …
The document about the flag _NTO_CHF_COID_DISCONNECT is
not very clear. When I turned to Robert Krten’s book, the
description
about this flag also made me confused.

Who could explain this flag in an easy-to-understand way, an example
would be very useful.
Assume process A calls ChannelCreate() with this flag set, process B
connects
this channel by calling ConnectAttach().

What is the difference between two cases (with and without this
flag)?
Thanks.

When B calles ConnectAttach(), it got back a “connection id”.
Actually,
a “server side connection id” (scoid) also created in Process A to
identify
the same connection.

Without the flag, if B ConnectDetach(coid), or crashed, or being
killed
by some sort of signal, A will never know, and have the scoid opened.

With the flag, anytime B gone, A got nitified (with a pulse, and scoid
in
pulse), A could then call ConnectDetach(scoid) to free the scoid.

-xtang


I thought the flag _NTO_CHF_DISCONNECT does what you said.
then what is difference between _NTO_CHF_DISCONNECT and
_NTO_CHF_COID_DISCONNECT?

Oops. Sorry for that. the _NTO_CHF_COID_DISCONNECT is the
otherway arround. Let’s try it again.

A ChannelCreate() and B ConnectAttach() to it, what happens if A
crashed, or it simply called ChannelDestroy() ? B wouldn’t get informed.
(B could call MsgSend() and try to hit a ESRCH or EBADF, but
that’s not for sure.)

What B would do is, it will ChannelCreate(_NTO_CHF_COID_DISCONNECT)
(note only one channel in a process allowed to set this flag). B will then
have a thread MsgReceive() on the channel to get the notification
that A is died…

Does this make sense now ?

-xtang

Jerry <xwindow@yahoo.com> wrote:

Great, right now everything is clear!. Thanks a lot.

Another question if you don’t mind.
the flag bit _NTO_MI_UNBLOCK_REG in MsgInfo will be set if the client
wishes to unblock.
I just don’t understand the the significance of this flag because
when I use _NTO_CHF_UNBLOCK in ChannelCreate(), the server will
receive a notification from the kernel indicating the client wishes to
unblock (thus
the thread in the server can set an internal flag itself to achive the same
goal).
So it seems that this flag (_NTO_MI_UNBLOCK_REG) is not necessary.
Does it have any special meaning or special use?

What if you have 2 threads in your server?

Thread 1 gets the message, and is working on it. Thread 2
gets the unblock pulse.

Now, thread 1 replies, and the client sends again… and is REPLY
blocked (but has not been hit by a signal, etc, so no pending unblock),
now thread 2 gets to run…how does it know if it should fail the
client? (Both sends from the same thread in the same client process
will give the same rcvid on the server side). It can check this flag
to see if it needs to unblock the client or not.

If your server is single-threaded, you will never need to worry about
this.

(Note: the above example would also probably need a mutex to prevent
certain race conditions as well.)

-David

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