🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
9 messages
9 total messages Started by David Ayre Wed, 14 Feb 2007 13:18
IdFTP1->List problem
#1379
Author: David Ayre
Date: Wed, 14 Feb 2007 13:18
10 lines
1039 bytes
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
Re: IdFTP1->List problem
#1380
Author: Remy Lebeau (TeamB)
Date: Wed, 14 Feb 2007 18:02
14 lines
1355 bytes
"David Ayre" <davidcayre@ntlworld.com> wrote in message
news:45d30c11$1@newsgroups.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
Re: IdFTP1->List problem
#1283
Author: David Ayre
Date: Thu, 15 Feb 2007 10:07
25 lines
1655 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>
>"David Ayre" <davidcayre@ntlworld.com> wrote in message
>news:45d30c11$1@newsgroups.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
Re: IdFTP1->List problem
#1284
Author: Tom
Date: Thu, 15 Feb 2007 14:41
13 lines
1470 bytes
> 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
Re: IdFTP1->List problem
#1285
Author: Remy Lebeau (TeamB)
Date: Thu, 15 Feb 2007 17:38
12 lines
1307 bytes
"David Ayre" <davidcayre@ntlworld.com> wrote in message
news:45d430c5$1@newsgroups.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
Re: IdFTP1->List problem
#1286
Author: David Ayre
Date: Thu, 15 Feb 2007 18:57
24 lines
1670 bytes
"Tom" <tom@nospam.net> wrote:
>> 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
Re: IdFTP1->List problem
#1287
Author: Tom
Date: Fri, 16 Feb 2007 01:53
26 lines
1935 bytes
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 
Re: IdFTP1->List problem
#1290
Author: David Ayre
Date: Fri, 16 Feb 2007 14:25
39 lines
1917 bytes
Thanks Tom,

That seems to have solved the problem.

Cheers,

David


"Tom" <tom@nospam.net> wrote:
>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 
>
>
Re: IdFTP1->List problem
#1293
Author: David Ayre
Date: Sun, 18 Feb 2007 19:06
26 lines
1660 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>
>"David Ayre" <davidcayre@ntlworld.com> wrote in message
>news:45d430c5$1@newsgroups.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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads