SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: FTP Sockets

  1. #1
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    FTP Sockets

    Hey,

    Currently writing script to connect with a FTP server in passive mode. Everything goes fine, until i get a LIST of the current directory. In passive mode, commands and data are sent on separate connections, hence, when i do a LIST command, i must have an open connection for the data to be sent. The problem is that the fgets() command on teh data socket is not ending even with while(!feof($dataSocket)) { } governing it. It will stop is i place fclose($dataSocket) immediately after, however, this is inefficient if i need to transfer several files / receive lots of data. I can receive the data (using flus()) to output, however the script just hangs on the fgets() receiving nothing. I even tried placing some random text, and it just hangs, it isn't infinite looping.

    Any ideas if this is the standard procedure for working with sockets and FTP? I can't find much in the RFC about it.

    Thanks

  2. #2
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried the FTP specific functions?

    http://uk.php.net/ftp

    Last time I played with the FTP functions I had a lot of problems. A lot of them end up entering a deadlock, and because there is no way to set any time out (like the Javascript setTimeOut() function), or any threading to get a 2nd thread to kill the FTP deadlock you end up just having to put up with this annoyance.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •