Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. FTP Question

FTP Question

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomsysadmintutorial
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cabadam
    wrote on last edited by
    #1

    How would I open a connection to an FTP server such that I could send actual commands to the server (ex: LIST, etc) and view the actual responses the server gives (Welcome messages, etc). I know how to use the CFtpConnection to do basic FTP stuff, but I don't think it does this. Anyone have any ideas? Adam cabadam@houston.rr.com

    L 1 Reply Last reply
    0
    • C Cabadam

      How would I open a connection to an FTP server such that I could send actual commands to the server (ex: LIST, etc) and view the actual responses the server gives (Welcome messages, etc). I know how to use the CFtpConnection to do basic FTP stuff, but I don't think it does this. Anyone have any ideas? Adam cabadam@houston.rr.com

      L Offline
      L Offline
      l a u r e n
      wrote on last edited by
      #2

      ummmm you could just open a socket @ port 21 and send the commands thru as most full-blown ftp programs do ... you'll need the rfc for the ftp protocol and all that and then its not too difficult ... i dont know if there is any windows source code available to show it but i'm sure there would be some unix stuff around that wouldn't be too different in the basics of sockets etc --- "every year we invent better idiot proof systems and every year they invent better idiots"

      C 1 Reply Last reply
      0
      • L l a u r e n

        ummmm you could just open a socket @ port 21 and send the commands thru as most full-blown ftp programs do ... you'll need the rfc for the ftp protocol and all that and then its not too difficult ... i dont know if there is any windows source code available to show it but i'm sure there would be some unix stuff around that wouldn't be too different in the basics of sockets etc --- "every year we invent better idiot proof systems and every year they invent better idiots"

        C Offline
        C Offline
        Cabadam
        wrote on last edited by
        #3

        Ok, still problem though: I am using a derived CAsyncSocket (CFtpSocket) for initial connection. (Tried this with both CSocket and CAsyncSocket) When I call the Connect(host,port), it returns true, giving me the initial socket connection. However, at that point, shouldn't I get a welcome message? I have been comparing what my program gives to what CuteFTP gives, and it says: STATUS:> Connect: Monday 17:10:21 05-07-2001 STATUS:> Connecting to ftp.angelfire.com STATUS:> Connecting to ftp.angelfire.com (ip = 216.33.20.80) STATUS:> Socket connected. Waiting for welcome message... 220 Hi! Welcome to Angelfire's NEW FTP. But in my program I never get that welcome message. It just stops after the socket connects. I have the OnReceive() overwritten and it SHOULD call that when I get the welcome message right? Or am I missing something? OnReceive is never getting called in my program. Adam cabadam@houston.rr.com

        L 1 Reply Last reply
        0
        • C Cabadam

          Ok, still problem though: I am using a derived CAsyncSocket (CFtpSocket) for initial connection. (Tried this with both CSocket and CAsyncSocket) When I call the Connect(host,port), it returns true, giving me the initial socket connection. However, at that point, shouldn't I get a welcome message? I have been comparing what my program gives to what CuteFTP gives, and it says: STATUS:> Connect: Monday 17:10:21 05-07-2001 STATUS:> Connecting to ftp.angelfire.com STATUS:> Connecting to ftp.angelfire.com (ip = 216.33.20.80) STATUS:> Socket connected. Waiting for welcome message... 220 Hi! Welcome to Angelfire's NEW FTP. But in my program I never get that welcome message. It just stops after the socket connects. I have the OnReceive() overwritten and it SHOULD call that when I get the welcome message right? Or am I missing something? OnReceive is never getting called in my program. Adam cabadam@houston.rr.com

          L Offline
          L Offline
          l a u r e n
          wrote on last edited by
          #4

          ummm that is the ftp server answering a log-on request from the client app you have to establish the connection and send the required commands to get anything going that u can work with as i said ... check out the rfc on the ftp protocol to get a command list :suss: --- "every year we invent better idiot proof systems and every year they invent better idiots"

          C 1 Reply Last reply
          0
          • L l a u r e n

            ummm that is the ftp server answering a log-on request from the client app you have to establish the connection and send the required commands to get anything going that u can work with as i said ... check out the rfc on the ftp protocol to get a command list :suss: --- "every year we invent better idiot proof systems and every year they invent better idiots"

            C Offline
            C Offline
            Cabadam
            wrote on last edited by
            #5

            LOL OK.. Thats what I deserve for trying to think while tired. Turns out my socket was going out of scope and being destroyed... *face turns red* OK-- now I got my welcome message and I have read the RFC on FTP protocol so I understand pretty much how FTP is supposed to work. Now I need to actually send commands. :) Ok, lets say I have: CString command = "USER someone"; What do I need to tack on to the end of command to correctly send it? I know the RFC said to have a carriage return and line feed. Isn't that \r\n? I tried that and nothing happened after I sent it. Tried adding basically every combination ("\r", "\n", "\r\n", "\n\r", "") Still nothing worked. Also, to send it, I should just do this correct: char* buf = command.GetBuffer(command.GetLength()); Send(buf, sizeof(buf)); Thanks! Adam cabadam@houston.rr.com

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups