Developing a Robust Ftp Client in PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jalitt@gmail.com

    Developing a Robust Ftp Client in PHP

    Hello,

    I've been tasked with developing a lightweight ftp client for use in
    web servers. Obviously, there is no need to redesign the wheel, and
    I've basically just been wrapping a class around the ftp library
    functions in the php library. Now, this class works great for most
    purposes, however, when it encounters a flaky ftp server, I can get
    disconnected without warning.

    So basically, what is the best way to handle disconnects? I want to
    auto-reconnect to an ftp, I think that is the most sensible
    solution(if anyone has a better one, please let me know). Is there
    anyway to register a callback function that is called when
    disconnected from an ftp? If not, is there anyway to poll the status
    of the current ftp connection? Possibly I should just have a loop
    that sleeps, calls ftp_nlist(), if that fails then it attempts to
    reconnect. Then I could just spawn an ftp_client thread that
    continuously monitors the ftp connection until killed. Seems like
    overkill to me though.. I dunno, anyone have any better ideas?

    Sincerely,

    Joshua Litt
  • C. (http://symcbean.blogspot.com/)

    #2
    Re: Developing a Robust Ftp Client in PHP

    On Aug 6, 5:57 pm, jal...@gmail.co m wrote:
    Hello,
    >
    I've been tasked with developing a lightweight ftp client for use in
    web servers. Obviously, there is no need to redesign the wheel, and
    I've basically just been wrapping a class around the ftp library
    functions in the php library. Now, this class works great for most
    purposes, however, when it encounters a flaky ftp server, I can get
    disconnected without warning.
    >
    So basically, what is the best way to handle disconnects? I want to
    auto-reconnect to an ftp, I think that is the most sensible
    solution(if anyone has a better one, please let me know). Is there
    anyway to register a callback function that is called when
    disconnected from an ftp? If not, is there anyway to poll the status
    of the current ftp connection? Possibly I should just have a loop
    that sleeps, calls ftp_nlist(), if that fails then it attempts to
    reconnect. Then I could just spawn an ftp_client thread that
    continuously monitors the ftp connection until killed. Seems like
    overkill to me though.. I dunno, anyone have any better ideas?
    >
    Sincerely,
    >
    Joshua Litt
    Top of my list would be not to use ftp (have a google for previous
    rants). But since that's not an option, next solution would be to use
    a seperate connection for each transaction, closing it when completed,
    and always checking for errors along the way.

    There's not a lot you can do to fix other peoples' problems.

    C.

    Comment

    • jalitt@gmail.com

      #3
      Re: Developing a Robust Ftp Client in PHP

      Top of my list would be not to use ftp (have a google for previous
      rants). But since that's not an option, next solution would be to use
      a seperate connection for each transaction, closing it when completed,
      and always checking for errors along the way.
      >
      There's not a lot you can do to fix other peoples' problems.
      >
      C.
      Hah, that is a far more elegant solution then I was envisioning. I've
      gone ahead and implemented that, I guess it will add a little
      overhead to each transfer, but I think the pay off is worth it.

      Sincerely,

      Joshua Litt

      Comment

      Working...