Buy commercial curl support from WolfSSL. We help you work
out your issues, debug your libcurl applications, use the API, port to new
platforms, add new features and more. With a team lead by the curl founder
himself.
Re: TFTP get filesize/file exist
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Tomalak Geret'kal via curl-library <curl-library_at_cool.haxx.se>
Date: Wed, 24 Mar 2021 17:23:03 +0000
On 24/03/2021 14:45, Tomas Berger via curl-library wrote:
> I have been trying to create a function that returns true
> if a file exists or not on a TFTP server. I had a function
> for this for SFTP/FTP using CURLOPT_NOBODY, and that has
> been for those protocols. However, did not work for TFTP.
> I have managed to make a function that checks if a file
> exists on a TFTP server, I am just uncertain if this is
> the right way to go about it.
[snip]
> I am just wondering if there is an easier way to do this
> or if there is some CURLOPT for this?
>
Your approach seems reasonable to me. TFTP is very simple
and doesn't have any way to enumerate files short of
literally starting a transfer. You wouldn't be able to find
out how large a file is until you'd finished receiving it,
but if all you need to know is that it exists, then trying
to receive /some/ data is fine.
Since TFTP is a lockstep protocol, the server won't send any
blocks until the first one has been acknowledged. So, since
you're aborting the transfer after the first block, you're
not wasting any bandwidth with buffered data that then gets
thrown away.
I can't see any documented way to do this more directly with
libcurl options, nor do I think that any need to be added.
Cheers
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html
Received on 2021-03-24
Date: Wed, 24 Mar 2021 17:23:03 +0000
On 24/03/2021 14:45, Tomas Berger via curl-library wrote:
> I have been trying to create a function that returns true
> if a file exists or not on a TFTP server. I had a function
> for this for SFTP/FTP using CURLOPT_NOBODY, and that has
> been for those protocols. However, did not work for TFTP.
> I have managed to make a function that checks if a file
> exists on a TFTP server, I am just uncertain if this is
> the right way to go about it.
[snip]
> I am just wondering if there is an easier way to do this
> or if there is some CURLOPT for this?
>
Your approach seems reasonable to me. TFTP is very simple
and doesn't have any way to enumerate files short of
literally starting a transfer. You wouldn't be able to find
out how large a file is until you'd finished receiving it,
but if all you need to know is that it exists, then trying
to receive /some/ data is fine.
Since TFTP is a lockstep protocol, the server won't send any
blocks until the first one has been acknowledged. So, since
you're aborting the transfer after the first block, you're
not wasting any bandwidth with buffered data that then gets
thrown away.
I can't see any documented way to do this more directly with
libcurl options, nor do I think that any need to be added.
Cheers
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html
Received on 2021-03-24