[muscle] Re: Java API writes partial messages to network under some conditions

  • From: Jeremy Friesner <jaf@xxxxxxxxxxxx>
  • To: Lior Okman <lior.okman@xxxxxxxxxxxxxxxxxx>
  • Date: Tue, 2 Jan 2007 10:44:25 -0800

Hi Lior,

Thanks for the patch, I've added it into the subversion repository.  I do have 
one question though:  What happens when one of the flattenMessage() methods 
is called on a blocked TCP socket (e.g. after I've unplugged the computer's 
ethernet cable and its outgoing TCP buffer has filled up with data?)  It 
seems like out.write() would start returning zero, and therefore the while 
loop in your patch would spin forever, eating up 100% of the CPU time.  How 
is that handled in Java?  (in C++-land, I would use select() to detect when 
the socket had finally cleared up... but I don't know if there is any 
equivalent to select() in Java, so I always used blocking sockets there)

-Jeremy

On Tuesday 02 January 2007 08:26, Lior Okman wrote:
> Hi Jeremy,
>
>
> Attached is a fix for a situation where the amount of data written to
> the network is smaller than the amount of available data.
>
> This bug only occurs in situations where the socket being used is
> non-blocking. If the socket is a blocking socket (the default), the
> original code works OK.
>
>
> Thanks,
> Lior

Other related posts: