mkulke / ftplibpp

Platform independent c++ library providing ftp client functionality.
GNU Lesser General Public License v2.1
291 stars 108 forks source link

【Consultation】getservbyname alaways return NULL #41

Open ZhongYi-LinuxDriverDev opened 1 year ago

ZhongYi-LinuxDriverDev commented 1 year ago

I'm having some problems with the ftplib library and would like to ask you for advice. I failed to call Connect() in initramfs to log in to the FTP server. I checked the code of ftplib.cpp and found that getservbyname() returned a failure.

if ((pse = getservbyname("ftp","tcp")) == NULL)
    {
        perror("getservbyname");
        free(lhost);
        return 0;
    }

However,Connect in romfs can successfully login to the ftp server I tried to copy /etc/services from romfs to initramfs , but it still failed to log in. I do not know what is wrong, Can you give me some suggestions?

mkulke commented 1 year ago

in initramfs there might not be a libc implementation to resolve the hostname?