kathyayini
Programmer
Hi,
I called "TP_CALL" function in a thread which will send the data on the particular port to server and should receive the data. Currently the program sends the data properly but is not waiting till the data comes back (recv()). and the thread terminates.
Please help me out.
void* TP_CALL(void* data)
{
int bytesSent;
int condition = 0;
int i=0;
memset(&sd, '\0', sizeof(sd));
memset(cSendBuf, '\0', 2000);
strcpy(cSendBuf,"");
for (i=0; i<((struct sdata*) (data))->ibytes; i++)
{
if(((struct sdata*) (data))->cmsg < ' ') printf("."); else printf("%c", ((struct sdata*) (data))->cmsg);
}
bytesSent=send(((struct sdata*) (data))->sock_id,((struct sdata*) (data))->cmsg,((struct sdata*) (data))->ibytes,0);
int z=recv(((struct sdata*) (data))->sock_id,cSendBuf,MESSAGE_LENGTH,MSG_NOSIGNAL);
memcpy(&sd,cSendBuf,z);
for (i=0; i<z; i++)
{
if(sd.cstrmsg < ' ') printf("."); else printf("%c", sd.cstrmsg);
}
}
waiting for the reply.
I called "TP_CALL" function in a thread which will send the data on the particular port to server and should receive the data. Currently the program sends the data properly but is not waiting till the data comes back (recv()). and the thread terminates.
Please help me out.
void* TP_CALL(void* data)
{
int bytesSent;
int condition = 0;
int i=0;
memset(&sd, '\0', sizeof(sd));
memset(cSendBuf, '\0', 2000);
strcpy(cSendBuf,"");
for (i=0; i<((struct sdata*) (data))->ibytes; i++)
{
if(((struct sdata*) (data))->cmsg < ' ') printf("."); else printf("%c", ((struct sdata*) (data))->cmsg);
}
bytesSent=send(((struct sdata*) (data))->sock_id,((struct sdata*) (data))->cmsg,((struct sdata*) (data))->ibytes,0);
int z=recv(((struct sdata*) (data))->sock_id,cSendBuf,MESSAGE_LENGTH,MSG_NOSIGNAL);
memcpy(&sd,cSendBuf,z);
for (i=0; i<z; i++)
{
if(sd.cstrmsg < ' ') printf("."); else printf("%c", sd.cstrmsg);
}
}
waiting for the reply.