Michael Downey wrote:
> 
> Mark Berryman replied after this but I don't add it here as my mail viewer
> blocked his attachment.  But his argument was that it should be up to the
> programmer to code around the limitations of the OS.

If that is what you got from my posting then I wasn't clear.  Permit me
to restate:

This is NOT a limitation of the OS.  It is a documented requirement for
TCP-based network programming on ANY platform.

>  In some cases this is
> inevitable but in this case I would say we do not want to force this limit
> on the calling program.  What does it solve if we make the programmer do
> something like:
> 
> $num_remaining = sizeof(buffer);
> for ($i = 0; $i <= BUFFER_SIZE; $i += MAX_SIZE_TCPIP_CAN_TAKE)
> {
>     if ($num_remaining < MAX_SIZE_TCPIP_CAN_TAKE) {
>         write (buffer[$i], $num_remaining, ...);
>     }
> 
>     else
>     {
>         write (buffer[$i], $num_remaining, ...);
>      }
> }
> 

That would be wrong.  The following would be more like it:

$amount_to_be_written = sizeof(buffer);
$amount_written = 0;
while ($amount_written < $amount_to_be_written)
{
        $status =
write(buffer[$amount_written],$amount_to_be_written-$amount_written);
        if (status < 1) break;
        $amount_written += $status;
}
error checking...

Look at any major open-source program to see how it handles writes to
the network for examples.

Mark Berryman

Reply via email to