Re: Problem with PR_Recv in blocking mode.

"D3|\\||\\|!$" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.nspr
Organization http://groups.google.com
Message-ID <3351c1f9-1070-4569-8eeb-9d50f1a62315@i12g2000prf.googlegroups.com>
 Hi All!!!

I have found the reasons(explained below) for which it was behaving
erroneously. But this has given birth to more querries...!!! :-)


> 1)    The client is unable to send/recieve messages from the server in
> the first call to recieve/send. It requires exactly two messages
> before the communication actually starts between the client and the
> server. Once established, no errors occur. I have to find the cause of
> failure on the initial two attempts.

The problem was happening because I had called the client in non-
blocking mode and not properly checked the error codes returned by
PR_GetError()... I ran a loop and checked it for PR_IN_PROGRESS error
and called PR_Poll and then PR_GetConnectStatus... Also checked for
PR_WOULD_BLOCK error and repeated the loop(which called PR_Recv again)

> 2)    The server side(uses a blocking socket) on calling recieve
> returns properly with the first packet. Upon being called
> subsequently, it doesn't block(as expected) but returns with a single
> byte NULL character. If it is called again, then it blocks like any
> other blocking socket... This however, is not the case with the
> client(non-blocking). I have to figure out the cause of this as
> well..

On the client side, I had passed the PR_Send function the total length
of the buffer instead of just the length of the current buffer-
string... This made the server get an additional byte on the next call
to PR_Recv...


My question is:
"Why was this additional byte not recieved in the first call to
PR_Recieve itself??? How does this extra packet come into the
picture...??"

Warm Regards,
D3|\||\|!$
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.