Thread: I can't transfer file,who could help me?

  1. #1
    Registered User
    Join Date
    Jun 2011

    I can't transfer file,who could help me?

    My PC's OS is XP,and I install VMWare and its OS is linux.
    My XP has IIS and can transfer file using ftp,and now
    I write codes and I want to transfer file,but it can't,Look:

    //server ftp
    struct sockaddr_in adds;
    struct in_addr inp;
    bzero(&adds,sizeof(struct sockaddr_in));
    inet_aton("",&inp); //IP
    adds.sin_port=htons(21); //port
    //connect to server
    connect(skc,(struct sockaddr*)&adds,sizeof(struct sockaddr));//success

    //user name
    send(skc,user,strlen(user),0);//chae user[]="USER usernamer\n";
    send(skc,passwd,strlen(passwd),0);//char passwd[]="PASS passwd\n";
    //My client port,
    send(skc,cport,strlen(cport),0);//char cport[]="PORT 9999\n",
    //set mode
    send(skc,typestr,strlen(typestr),0);//char typestr[]="TYPE A\n";
    //I want to get the file 10.c
    send(skc,cmds,strlen(cmds),0);//char cmds[]="RETR 10.c\n";
    send(skc,qexit,strlen(qexit),0);//char qexit[]="QUIT\n";

    I want to know how to correct?thank you very much.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Does the command line FTP program which comes with windows work?

    Is that your actual code, or just something you paraphrased for our confusion?

    Have you actually read the FTP RFC to find out how it is supposed to work?

    Wireshark would allow you to easily compare what your code is doing with what a known working FTP program is doing.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 11-08-2010, 02:03 PM
  2. File Transfer?
    By illiterate in forum C++ Programming
    Replies: 3
    Last Post: 07-23-2010, 04:35 AM
  3. usb-to-usb file transfer using C/C++
    By young_virtuoso in forum Networking/Device Communication
    Replies: 1
    Last Post: 12-25-2006, 09:59 AM
  4. File Transfer
    By rogue in forum C++ Programming
    Replies: 6
    Last Post: 01-25-2006, 07:57 AM
  5. file transfer
    By shamila in forum C++ Programming
    Replies: 5
    Last Post: 04-23-2002, 12:09 PM