Multiplexing socket and message queue using Select()

I have a socket and a message queue over which i am trying to multiplex input using select().

When data comes over socket the select works but when it comes over message queue the select is not detecting it .

Create_Q gets the identifier of the messege queue.

/*********************CODE******************/

fd_set readfds;
struct msgbuf msg;
int msgPipe;

msgPipe=Create_Q("/tmp/Key",'a');
printf("Message queue id: %d \n",msgPipe);

FD_ZERO(&readfds);
FD_SET(msgPipe,&readfds);
FD_SET(hServerSocket,&readfds);

select(msgPipe+1, &readfds, NULL, NULL,NULL);

if (FD_ISSET(hServerSocket, &readfds))
printf("Data on socket\n");
else
printf("Data on Queue\n");

Message queues don't work like file descriptors, and can't be used with [tt]select()[/tt].

The usual way around this is to fork a subprocess which waits on the message queue and writes the data down a pipe to the main process, which can be [tt]select()[/tt]-ed.