BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

IdFTP1->List problem

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Socket)
View previous topic :: View next topic  
Author Message
David Ayre
Guest





PostPosted: Wed Feb 14, 2007 7:18 pm    Post subject: IdFTP1->List problem Reply with quote



Hi,

I am using Indy 9 with BDS 2006 but have found a problem with the
ftp module when I use IdFTP1->List(SL,"",false); If there is
nothing in the folder it crashes. What can I do to avoid this?

Cheers,

David
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Feb 15, 2007 12:02 am    Post subject: Re: IdFTP1->List problem Reply with quote



"David Ayre" <davidcayre (AT) ntlworld (DOT) com> wrote in message
news:45d30c11$1 (AT) newsgroups (DOT) borland.com...

Quote:
I am using Indy 9 with BDS 2006 but have found a problem
with the ftp module when I use IdFTP1->List(SL,"",false); If
there is nothing in the folder it crashes.

The server is likely sending back a faulty reply. Look at the "Indy
FTP Response Codes for NLST" discussion in the
"borland.public.delphi.internet.winsock" newsgroup from last night.


Gambit
Back to top
David Ayre
Guest





PostPosted: Thu Feb 15, 2007 4:07 pm    Post subject: Re: IdFTP1->List problem Reply with quote



"Remy Lebeau \(TeamB\)" <no.spam (AT) no (DOT) spam.com> wrote:
Quote:

"David Ayre" <davidcayre (AT) ntlworld (DOT) com> wrote in message
news:45d30c11$1 (AT) newsgroups (DOT) borland.com...

I am using Indy 9 with BDS 2006 but have found a problem
with the ftp module when I use IdFTP1->List(SL,"",false); If
there is nothing in the folder it crashes.

The server is likely sending back a faulty reply. Look at the "Indy
FTP Response Codes for NLST" discussion in the
"borland.public.delphi.internet.winsock" newsgroup from last night.


Gambit


I've had a look at the NLST discussion but couldn't glean

anything that would help me.
If the server gives the wrong response to IdFTP1->List(SL,"",false);
for an empty folder, how can I detect this and continue,
ignoring the List(), which would then be unnecessary?

David
Back to top
Tom
Guest





PostPosted: Thu Feb 15, 2007 8:41 pm    Post subject: Re: IdFTP1->List problem Reply with quote

Quote:
If the server gives the wrong response to IdFTP1->List(SL,"",false);
for an empty folder, how can I detect this and continue,

Indy uses Exceptions therefore if a bad response is received an exception
should be thrown. That being the case you need to use try/catch to catch
the exceptions and deal with them accordingly.

If an exception isn't thrown, you should check the response code that
is returned and determine your action from there.

Regards,

Tom
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Feb 15, 2007 11:38 pm    Post subject: Re: IdFTP1->List problem Reply with quote

"David Ayre" <davidcayre (AT) ntlworld (DOT) com> wrote in message
news:45d430c5$1 (AT) newsgroups (DOT) borland.com...

Quote:
I've had a look at the NLST discussion but couldn't glean
anything that would help me.

Then I suggest you use a packet sniffer, such as Ethereal, to find out
exactly what the server is sending.


Gambit
Back to top
David Ayre
Guest





PostPosted: Fri Feb 16, 2007 12:57 am    Post subject: Re: IdFTP1->List problem Reply with quote

"Tom" <tom (AT) nospam (DOT) net> wrote:
Quote:
If the server gives the wrong response to IdFTP1->List(SL,"",false);
for an empty folder, how can I detect this and continue,

Indy uses Exceptions therefore if a bad response is received an exception
should be thrown. That being the case you need to use try/catch to catch
the exceptions and deal with them accordingly.

If an exception isn't thrown, you should check the response code that
is returned and determine your action from there.

Regards,

Tom

Thanks Tom,


I thought something like that would do it, but I'm not sure how
to set it out. Could you possibly give me a code example.

Cheers,

David
Back to top
Tom
Guest





PostPosted: Fri Feb 16, 2007 7:53 am    Post subject: Re: IdFTP1->List problem Reply with quote

David,

Without knowing the exact exception that's being thrown, I can only
give you a general try catch example. Once you get the exception
name I would only catch that exception so you can deal with any
others that may show up accordlingly.

try
{
IdFTP1->List(SL, "", false);
}
catch (Exception &e)
{
// This will catch every exception and handle them the same
// way. If you have different exceptions coming up, you need to
// catch them separately by using the proper names.
// IE: catch (EIdSocketError &e) or catch (EIdProtocolReplyError)

// If you need to do something special, put that code here.
// otherwise the error message will disappear. Please remember
// that the error will still be shown if you're using the debugger.
}

Regards,

Tom
Back to top
David Ayre
Guest





PostPosted: Fri Feb 16, 2007 8:25 pm    Post subject: Re: IdFTP1->List problem Reply with quote

Thanks Tom,

That seems to have solved the problem.

Cheers,

David


"Tom" <tom (AT) nospam (DOT) net> wrote:
Quote:
David,

Without knowing the exact exception that's being thrown, I can only
give you a general try catch example. Once you get the exception
name I would only catch that exception so you can deal with any
others that may show up accordlingly.

try
{
IdFTP1->List(SL, "", false);
}
catch (Exception &e)
{
// This will catch every exception and handle them the same
// way. If you have different exceptions coming up, you need to
// catch them separately by using the proper names.
// IE: catch (EIdSocketError &e) or catch (EIdProtocolReplyError)

// If you need to do something special, put that code here.
// otherwise the error message will disappear. Please remember
// that the error will still be shown if you're using the debugger.
}

Regards,

Tom

Back to top
David Ayre
Guest





PostPosted: Mon Feb 19, 2007 1:06 am    Post subject: Re: IdFTP1->List problem Reply with quote

"Remy Lebeau \(TeamB\)" <no.spam (AT) no (DOT) spam.com> wrote:
Quote:

"David Ayre" <davidcayre (AT) ntlworld (DOT) com> wrote in message
news:45d430c5$1 (AT) newsgroups (DOT) borland.com...

I've had a look at the NLST discussion but couldn't glean
anything that would help me.

Then I suggest you use a packet sniffer, such as Ethereal, to find out
exactly what the server is sending.


Gambit


Thanks Remy,


Ive downloaded that and got it going. In the meantime I just put
the List() into a try/catch and allowed it to ingore the
return when there was an empty folder.
Now I can check the return and make it more specific.

Thanks for your help.

David
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Socket) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.