I'm sending certain messages to my server and upon sending it off, i
would receive LOGOK back. I'm trying to accomplish reading it like
this:
reclen=send(m_sock, res, sndlen, 0);
for(s=0;s<10000000;s++);
if (reclen != sndlen) {
if (reclen==-1)
printf("send failed...,errno: %s!\n", strerror( errno ));
printf("nlog: \"%s\" not sent, strlen(%d) - sent %d\n",res,
sndlen, reclen);
}
else
printf("sent %s-------------\n", res);
if(recv(m_sock, recbuf, sizeof(recbuf), 0) > -1)
printf("RECEIVED:%s--------------\n",recbuf);
else
printf("recv failed...,errno: %s!\n", strerror( errno ));
Now my problems is that the program seems to be hanging in the recv
function. it doesn't go ahead and not show me the RECEIVED string nor
i see recv failed. What may be the problem here?
Thanks!
Ron
What is the purpose of the 'for' loop? And why use 'send' with zero
options?
> if (reclen != sndlen) {
> if (reclen==-1)
> printf("send failed...,errno: %s!\n", strerror( errno ));
> printf("nlog: \"%s\" not sent, strlen(%d) - sent %d\n",res,
> sndlen, reclen);
> }
> else
> printf("sent %s-------------\n", res);
> if(recv(m_sock, recbuf, sizeof(recbuf), 0) > -1)
> printf("RECEIVED:%s--------------\n",recbuf);
> else
> printf("recv failed...,errno: %s!\n", strerror( errno ));
>
> Now my problems is that the program seems to be hanging in the recv
> function. it doesn't go ahead and not show me the RECEIVED string nor
> i see recv failed. What may be the problem here?
That doesn't indicate a problem. That simply indicates that your code
is doing what you asked it to do -- attempting to read data forever,
until it either succeeds, fails, or is interrupted. It has done none
of those three things.
DS