ressource managers and threads

I’m a little bit lost!!!

When we write a simple server application which is able to create thread we need to have something like:

typedef union{
struct _pulse pulse;
struct my_message msg;
}msg_t;


msg_t msg;

rcvid = MsgReceive(…)

switch (rcvid)
{
case 0:
switch(msg.pulse.code)
{
case _PULSE_CODE_DISCONNECT:
ConnectDetach(Msg.pulse.scoid);
break;
}
break;

}



Now consider a server application developped as a ressource manager, able to receive IO_MSG and able to create a thread to do something, depending on the received message.
the message type is:

typedef union{
struct _io_msg io_msg;
struct _pulse pulse;
};

In the application we have:

for_ever{
ctp = dispatch_block(ctp);

dispatch_handler(ctp);
}

My problem is how can I catch the pulse to call the ConnectDetach()??


I have a second problem which maybe is the same.

After I killed the thread, my ressource manager exits, why ??

Third, If I printf() the message type received I see the following sequence:

IO_CONNECT
IO_MSG
IO_CLOSE
0

What is 0 (zero)?

Thanks Alain.