IPC disconnect!

Hi there, i’m trying to find out how to gracfully close an ipc connection on the client side.

I have a server and a client. When the client process ends the server receives a message (MsgReceive) with an errno 14, EFAULT.

How can i gracefully close the connection before i end the client process without getting this message on the server?

My current code attempt is:

[code]void IPC_comms_deinit(void)
{
int test = 0;

test = ConnectDetach(self_coid);
DC3_error(ERROR_LEVEL_DEBUG, 0L, "Close connection: %d", test);
sleep(2);

test = ChannelDestroy( chid );
DC3_error(ERROR_LEVEL_DEBUG, 0L, "Close connection: %d", test);
sleep(2);

test = name_close( server_coid );
DC3_error(ERROR_LEVEL_DEBUG, 0L, "Close connection: %d", test);
sleep(2);

}[/code]

I added the sleeps to see when i get the error message on the server side and its on the name_close() call. All these calls (ConnectDetach, ChannelDestroy & name_close) return 0, so the calls are successful!

Any ideas?

Cheers