Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

waiting for ack

0 views
Skip to first unread message

cerr

unread,
Dec 29, 2009, 1:50:41 PM12/29/09
to
Hi There,

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

David Schwartz

unread,
Dec 29, 2009, 2:37:15 PM12/29/09
to
On Dec 29, 10:50 am, cerr <ron.egg...@gmail.com> wrote:
> Hi There,
>
> 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++);

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

0 new messages