note 11222 deleted from function.fsockopen by jimw

From: Date: Sat, 08 Dec 2001 21:56:51 +0000
Subject: note 11222 deleted from function.fsockopen by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22252@lists.php.net to get a copy of this message
If you're trying to connect to an FTP address without using ftp_connect(); then you can do this: $tftp = fsockopen("ftp.blah.com", 21, $errno, $errstr, 60) or die("Connection failed."); socket_set_blocking($tftp, false); fputs($tftp, "USER username\n"); fputs($tftp, "PASS password\n"); fputs($tftp, "DELE /home/somefilename.blh\n"); sleep(1); fclose($tftp); NOTE THE "sleep(1);" THIS IS REQUIRED. I had a few problems where it was not executing the commands if I had not added the a delay after the actual fput requests. I guess what was happening was that it was closing the FTP connection before it could actually finish the commands on the servers side.

« previous php.notes (#22252) next »