Skip to content

lpsky/start-linux-ftp-server

 
 

Repository files navigation

a linux ftp server for beginner

A mini linux ftpd developed in C program language on ubuntu 12.04, it is a multi-process framework server.

如果发现PORT与PASV模式无法工作,可能原因是无法准确获取本地IP地址。可以尝试下面这种方法获取ip。

int getlocalip(const char *ip)
{
    int sockfd; 
    if(-1 == (sockfd = socket(PF_INET, SOCK_STREAM, 0)))
    {
        perror( "socket" );
        return -1;
    }
    struct ifreq req;
    struct sockaddr_in *host;
    bzero(&req, sizeof(struct ifreq));
    strcpy(req.ifr_name, "eth0"); 
    ioctl(sockfd, SIOCGIFADDR, &req);
    host = (struct sockaddr_in*)&req.ifr_addr;
    strcpy(ip, inet_ntoa(host->sin_addr));
    close(sockfd);
    return 1;
}

About

ftpserver

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 98.7%
  • Other 1.3%