How can a server wake up a blocking client?

Suppose I use a while loop to let server keep on receiving from and
replying message to its clients.

If the server ignore the worker1’s Msgsend( ) in the 1st loop and let
worker1 enter the block state, and server keep on receiving other Msgsend()
by other workers in the following loop, how can the server “wake up” worker1
again latter?

Since worker1 is already in block state, it won’t be able to send signal to
server again. Even the server implement MsgReceive() in next loop, it won’t
receive signal from worker1…

Replied to in qdn.public.newuser. Please, make up your mind and post in
one place please, it’s kinda rude.

Daryl Low

Shirley wrote:

Suppose I use a while loop to let server keep on receiving from and
replying message to its clients.

If the server ignore the worker1’s Msgsend( ) in the 1st loop and let
worker1 enter the block state, and server keep on receiving other Msgsend()
by other workers in the following loop, how can the server “wake up” worker1
again latter?

Since worker1 is already in block state, it won’t be able to send signal to
server again. Even the server implement MsgReceive() in next loop, it won’t
receive signal from worker1…

Shirley <novice@hongkong.com> wrote:

Suppose I use a while loop to let server keep on receiving from and
replying message to its clients.

If the server ignore the worker1’s Msgsend( ) in the 1st loop and let
worker1 enter the block state, and server keep on receiving other Msgsend()
by other workers in the following loop, how can the server “wake up” worker1
again latter?

Since worker1 is already in block state, it won’t be able to send signal to
server again. Even the server implement MsgReceive() in next loop, it won’t
receive signal from worker1…

If you are going to delay replaying to a particular client, then you need
to save the rcvid that matches the MsgSend that you are leaving blocked
until later. Once it is time to reply, just MsgReply() to the saved
rcvid, and you will wake up the client.

e.g.

while(1)
{
rcvid = MsgReceive( … )
// error checking

switch (msg.type )
{
case reply_now:
MsgReply( rcvid, … )
break;
case reply_later:
save_rcvid = rcvid;
break;
case later:
MsgReply( save_rcvid, … )
MsgReply( rcvid, … )
break;
}
}

Of course, if you might have several block workers (clients), then
you couldn’t just use a simple save_rcvid variable, it would be
more like:

add_rcvid_to_list( rcvid, why );

And:
unblock_rcvid = find_rcvid_in_list( why );

-David

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

Oh, I am terribly sorry about that.
“Daryl Low” <dlo*w@qnx.com> ¼¶¼g©ó¶l¥ó·s»D:3E6F0DE7.40804@qnx.com

Replied to in qdn.public.newuser. Please, make up your mind and post in
one place please, it’s kinda rude.

Daryl Low

Shirley wrote:
Suppose I use a while loop to let server keep on receiving from and
replying message to its clients.

If the server ignore the worker1’s Msgsend( ) in the 1st loop and let
worker1 enter the block state, and server keep on receiving other
Msgsend()
by other workers in the following loop, how can the server “wake up”
worker1
again latter?

Since worker1 is already in block state, it won’t be able to send signal
to
server again. Even the server implement MsgReceive() in next loop, it
won’t
receive signal from worker1…

\

Hi Shirley

It is quite common for a client to send a message that boils down to:
“let me know when … happens”. That message may get replied to
seconds, minutes, days or months later, or never.

i.e. select() or ionotify()