Discuss (FTP), (FTP on .NET CF) and (FTPS, SFTP and SCP).

Bug

no avatar
User

eli_h1

Bug

by eli_h1 » Tue Mar 09, 2004 2:20 am

Hi!

First of all, your code, guys, is great written.

The second thing is: when calling FtpClient.Dir(), System.IO.IOException thrown sometimes from FTPControlSocket.ReadReply on reader.ReadLine().

Didn't check it with other calls.

For naive me it seems to happen when line not yet ready in the stream: I'm requesting VERY remote ftp site.

IMHO, a simple reading loop with 10 milliseconds sleep will solve the problem.
no avatar
User

dnel

found the same problem

by dnel » Thu May 06, 2004 2:44 pm

great code! just having this same problem. I tried to edit it like so, but my code didn't work and it hangs:

StringBuilder reply = new StringBuilder();
bool madeIt = false;
try
{
// dn edit: 5-5-04
string firstLine = null;
try
{
firstLine = reader.ReadLine();
}
catch(System.IO.IOException)
{
while(firstLine == null)
{
firstLine = reader.ReadLine();
}
}
if (firstLine == null || firstLine.Length == 0)
throw new IOException("Unexpected null reply received");

reply.Append(firstLine);

if (debugResponses)
log.WriteLine(reply.ToString());

string replyCode = reply.ToString().Substring(0, 3);

// check for multiline response and build up
// the reply
if (reply[3] == '-')
{
bool complete = false;
while (!complete)
{
string line = reader.ReadLine();
if (line == null)
throw new IOException("Unexpected null reply received");

if (debugResponses)
log.WriteLine(line);

if (line.Length > 3 && line.Substring(0, 3).Equals(replyCode) && line[3] == ' ')
{
reply.Append(line.Substring(3));
complete = true;
}
else
{
// not the last line
reply.Append(" ");
reply.Append(line);
}
} // end while
}
madeIt = true;
}
catch(Exception ex)
{
string myException = ex.ToString();
while(madeIt == false)
{
this.ReadReply();
}
}
no avatar
User

dnel

fixed - was timeout!

by dnel » Thu May 06, 2004 2:48 pm

I thought the timeout was seconds, so I set it to 300 to start. I think it's actually milliseconds, so I changed it to 3000 and now it works great!! sweeeeeeeeeeeeeeeeet. :-)

Who is online

Users browsing this forum: No registered users and 127 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign