MsgSend / MsgReceive problem

Hi
i am new so i might be overlooking something.

i tried to use the MsgSend & MsgReceive without luck.

in my main function i have :

void main (void)
{
pthread_t ptTaskprocesserThread;

chid= ChannelCreate(0);



start sending threads

pthread_create(&ptTaskprocesserThread, NULL, &TaskprocesserThreadFunc,
NULL );


}

in my sending thread i have this :
MsgSend(chid, &senddata,sizeof(senddata),&response,sizeof(response));
I notice that MsgReive blocks ,but MsgSend returns -1

Whats wrong in my code ?

Johan



this is my client thread code to receive a message

void* TaskprocesserThreadFunc(void *vArguments)
{
int receivedvar,replyvar;
int iReceiveIdentifier;
printf(“Thread initialised\n”);
// Infinite loop
while(1)
{
// Receive the message
iReceiveIdentifier = MsgReceive(chid,
&receivedvar,sizeof(receivedvar), NULL);
// Check if this is a message
if(iReceiveIdentifier != -1)
{
printf(“Message received with value %d \n”, receivedvar);
replyvar=2 * receivedvar;
// Send the reply
if(MsgReply(iReceiveIdentifier, 1, &replyvar, sizeof(replyvar))
== -1)
printf("[Client] Error sending reply: %s \n", strerror(errno));
}
}
// Display the destruction message
printf(“Destroying task thread\n”);
return 0;
}

“Sagaert Johan” <sagaert.j@belgacom.net> wrote in message
news:cdpcc8$74o$1@inn.qnx.com

Hi
i am new so i might be overlooking something.

i tried to use the MsgSend & MsgReceive without luck.

in my main function i have :

void main (void)
{
pthread_t ptTaskprocesserThread;

chid= ChannelCreate(0);



start sending threads

pthread_create(&ptTaskprocesserThread, NULL, &TaskprocesserThreadFunc,
NULL );


}

in my sending thread i have this :
MsgSend(chid, &senddata,sizeof(senddata),&response,sizeof(response));
I notice that MsgReive blocks ,but MsgSend returns -1

MsgSend needs to be send over a connection id not a channel Id, you need to
ConnectAttach() to the chid

Whats wrong in my code ?

Johan



this is my client thread code to receive a message

void* TaskprocesserThreadFunc(void *vArguments)
{
int receivedvar,replyvar;
int iReceiveIdentifier;
printf(“Thread initialised\n”);
// Infinite loop
while(1)
{
// Receive the message
iReceiveIdentifier = MsgReceive(chid,
&receivedvar,sizeof(receivedvar), NULL);
// Check if this is a message
if(iReceiveIdentifier != -1)
{
printf(“Message received with value %d \n”, receivedvar);
replyvar=2 * receivedvar;
// Send the reply
if(MsgReply(iReceiveIdentifier, 1, &replyvar, sizeof(replyvar))
== -1)
printf("[Client] Error sending reply: %s \n", strerror(errno));
}
}
// Display the destruction message
printf(“Destroying task thread\n”);
return 0;
}