"Mark Berryman" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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
Maybe you are missing what the initial problem is with VMS.  You can not
write a buffer that is > 64K to a socket.  If you try the socket will fail
to send ANY data, I even think there was a crash bug in the code that's
likely been fixed.  So your above example would have to be even more
complicated.  Basically you'd have to encorperate my example and your
example together to get the bullet proof code.

As far as I can tell you should only need to use your checks if you set the
socket into a non-blocking state.  I do realize that some operating systems
can return back before they've sent all the data even when non-blocking
isn't set, but so far all the systems I've tested on don't do this any more
and just block until all data is away.  I might be sitting on a big problem
but I don't do any non-blocking I/O so I don't handle the case where the
write might return before it's sent everything.  It hasn't bit me yet but I
probably should fix it just to be safe.

Thanks for the clarification, I hope this clarifys the problem more for you.
I haven't verified that VMS has fix this problem since 7.3 so maybe in the
last release they've fixed it.  But since we are seeing the problem in perl
I'd assume we still have the problem.


Reply via email to