Re: size limit for byte array?

From: Lasse Vågsæther Karlsen (lasse_at_vkarlsen.no)
Date: 01/14/05


Date: Fri, 14 Jan 2005 08:06:33 +0100

Ron wrote:
> Hello,
>
> I am trying to read a list of files from an FTP server
> (mainframe) to a byte array using sockets as follows, but
> not getting all the files in a given directory:
>
<snip>

Sockets are streaming in nature, and while you might create a 16KB byte
array on one end and send off using 1 statement, you're not really
guaranteed to get it back in one call to Receive on the other end.

For all you know, you can get any number of blocks of data, ranging from
1 byte and upwards in size.

Instead of breaking the loop on "less than full buffer", try breaking it
on "empty buffer".

-- 
Lasse Vågsæther Karlsen
http://www.vkarlsen.no/
mailto:lasse@vkarlsen.no
PGP KeyID: 0x0270466B


Relevant Pages

  • Re: Can I use a byte array for sound files?
    ... Sound and sockets are off-topic in comp.lang.c but there are some ... You can read *ANY* readable file into a byte array (well, ... of data from the keyboard, and disk files, but it may be a bit more ...
    (comp.lang.c)
  • Re: socket programming
    ... > using sockets we exchange text between endpoints of the socket but ... > first we convert the text to array of bytes and we send it to the other ... For sending a binary integer to an endpoint, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: File transfer
    ... byte array of that size, ... Ciaran O''Donnell wrote: ... through sockets. ... the receivers end. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: file.seek and unused bytes
    ... in an Array and write it to a file ... breaking the current interfaces. ... It would use a little more RAM, but would eliminate calculating that offset each time during reads. ...
    (comp.lang.ruby)
  • Re: convert fd to IO object in extension?
    ... >>network sockets and disk file I/O. ... Caller creates an instance of Epoll ... add the IO object to a Hash and also call epoll_ctlto add ... that returns, builds an array of 2-cell arrays, the first cell containing ...
    (comp.lang.ruby)