R
Ron
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:
private readonly static int BUFFER_SIZE = 3300;
private byte[] buffer = new byte[BUFFER_SIZE];
private Encoding ASCII = Encoding.ASCII;
Socket socket = null;
int bytes;
string temp = "";
socket = CreateDataSocket(); //get connection here
SendCommand("NLST " + mask);
//while(true){
Array.Clear(buffer, 0, buffer.Length);
bytes = socket.Receive(buffer, buffer.Length, 0);
temp += ASCII.GetString(buffer, 0, bytes);
Console.WriteLine(temp);
//if( bytes < buffer.Length) break;
//}
I was originally looping in a while loop but got less than
if I just increased BUFFER_SIZE and just picked up
whatever temp would hold in one pass. At 3300 I get 2900
bytes worth of data. At 4096 I still only get 2900 or so
bytes of data into temp. There are about 5000 bytes of
data in this directory. What can I do to get all the
bytes of data into temp?
Thanks,
Ron
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:
private readonly static int BUFFER_SIZE = 3300;
private byte[] buffer = new byte[BUFFER_SIZE];
private Encoding ASCII = Encoding.ASCII;
Socket socket = null;
int bytes;
string temp = "";
socket = CreateDataSocket(); //get connection here
SendCommand("NLST " + mask);
//while(true){
Array.Clear(buffer, 0, buffer.Length);
bytes = socket.Receive(buffer, buffer.Length, 0);
temp += ASCII.GetString(buffer, 0, bytes);
Console.WriteLine(temp);
//if( bytes < buffer.Length) break;
//}
I was originally looping in a while loop but got less than
if I just increased BUFFER_SIZE and just picked up
whatever temp would hold in one pass. At 3300 I get 2900
bytes worth of data. At 4096 I still only get 2900 or so
bytes of data into temp. There are about 5000 bytes of
data in this directory. What can I do to get all the
bytes of data into temp?
Thanks,
Ron