473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

FTP unable to connect with fsockopen

I am trying to implement FTP in a PHP script but am unable to make the
connection to the remote server. The connection step times out at the
fsockopen function. I am not sure if it is relevant but PHP is
configured with "allow_url_fopen" ON. I am able to do an FTP connect
using an FTP client and using the same host/username/password
parameters.

Any ideas would be appreciated.

Thanks

Nov 2 '07 #1
4 3769
On 2 Nov, 15:28, MikeofPet <mike.g...@comcast.netwrote:
I am trying to implement FTP in a PHP script but am unable to make the
connection to the remote server. The connection step times out at the
fsockopen function. I am not sure if it is relevant but PHP is
configured with "allow_url_fopen" ON. I am able to do an FTP connect
using an FTP client and using the same host/username/password
parameters.

Any ideas would be appreciated.

Thanks
It's difficult to say what's happenning without a lot more info, but I
can't help thinking you're making life a lot more difficult than it
needs to be: allow_url_fopen option applies to the file access
wrappers - not fsockopen - but I'd be using the file wrappers method
in preference to implementing my own protocol stack (particularly with
FTP) - but even then I'd prefer to implement it using the curl
library.

When you say it works an FTP client - I assume you are using it
interactively from the command line - try executing it from within
your script (see http://www.php.net/manual/en/ref.exec.php). Note most
versions of the ftp client will happily work with input from a file
redirected to STDIN

C.

Nov 2 '07 #2
On Nov 2, 9:45 am, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
On 2 Nov, 15:28, MikeofPet <mike.g...@comcast.netwrote:
I am trying to implement FTP in a PHP script but am unable to make the
connection to the remote server. The connection step times out at the
fsockopen function. I am not sure if it is relevant but PHP is
configured with "allow_url_fopen" ON. I am able to do an FTP connect
using an FTP client and using the same host/username/password
parameters.
Any ideas would be appreciated.
Thanks

It's difficult to say what's happenning without a lot more info, but I
can't help thinking you're making life a lot more difficult than it
needs to be: allow_url_fopen option applies to the file access
wrappers - not fsockopen - but I'd be using the file wrappers method
in preference to implementing my own protocol stack (particularly with
FTP) - but even then I'd prefer to implement it using the curl
library.

When you say it works an FTP client - I assume you are using it
interactively from the command line - try executing it from within
your script (seehttp://www.php.net/manual/en/ref.exec.php). Note most
versions of the ftp client will happily work with input from a file
redirected to STDIN

C.
Thank you for comments - very helpful.

Nov 2 '07 #3
On Nov 2, 4:28 pm, MikeofPet <mike.g...@comcast.netwrote:
I am trying to implement FTP in a PHP script but am unable to make the
connection to the remote server. The connection step times out at the
fsockopen function. I am not sure if it is relevant but PHP is
configured with "allow_url_fopen" ON. I am able to do an FTP connect
using an FTP client and using the same host/username/password
parameters.

Any ideas would be appreciated.

Thanks
Haven't worked with fsockopen, but I know I hadn't had any problems
with socket_create, socket_connect, gethostbyname, socket_write,
socket_recv, socket_read socket functions family. Maybe you should try
that, it's not so hard. Of course, check if you're opening the correct
port, since it's not a mandatory argument in fsockopen, maybe you
forgot to give the ftp port (it can vary from ftp server to ftp
server, but is often 21, it's standard). Writing php code that relies
on allow_url_fopen maybe isn't that good, since you don't know how
many servers support it.

Nov 2 '07 #4
Mike,

Learn about these two PHP functions:

stream_set_blocking()
stream_set_timeout()

Cheers!

Vladimir
http://www.Vladimirated.com
On Nov 2, 3:28 pm, MikeofPet <mike.g...@comcast.netwrote:
I am trying to implement FTP in a PHP script but am unable to make the
connection to the remote server. The connection step times out at the
fsockopen function. I am not sure if it is relevant but PHP is
configured with "allow_url_fopen" ON. I am able to do an FTP connect
using an FTP client and using the same host/username/password
parameters.

Any ideas would be appreciated.

Thanks

Nov 3 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andrew Montgomery | last post by:
If anybody has experienced the following SquirrelMail error: Warning: fsockopen(): unable to connect to xx.xx.xx.xx:143 in /home/virtual/siteX/fst/var/www/squirrelmail/functions/imap_general.php...
2
by: Chris | last post by:
Hi All, I've been puzzling over this, but can't find a satisfactory answer anywhere. I'm not sure if the problem is in my code, or if it's something to do with the PHP/Apache set-up (probably...
1
by: connections cardiff | last post by:
hi, i am making a little prject in php and wondered if any of you more experienced developers could shed some light on a query. i want to connect to a server, give it some data then check it's...
5
by: meenasamy | last post by:
Hi all i have used a script that i downloaded and uses the fopen($url,'r'); function to access a url to retrieve data and i get this error Fatal error: fopen(): Unable to find the wrapper...
8
by: Yoko | last post by:
So I am using php version 4.3.9 and lets say i have a file on the server called tester.php so i am using fsockopen to point to that file but it gives me a error below. $fh =...
4
by: newladder | last post by:
Hi all, Iam struck with one of the problem with postgres. Please help me out.... Iam trying to connect to connect to postgres database on remote machine with the IP address 10.2.1.4. Iam unable...
1
by: panprasath | last post by:
hi, i am doing smtp mail program.In this program i use the function PHP Warning: fsockopen() : unable to connect to 192.168.0.250:25 (An established connection was aborted by the software in...
3
by: ros | last post by:
Hi! I have a simple PHP script: $mbox = imap_open ("{localhost:993/imap/ssl}INBOX", "test@domain.com", "123"); if(!$mbox) { echo 'Error: '.imap_last_error().'<br/>'; } Script works fine...
0
by: smokenlinks | last post by:
I am working on a script and i get this error Warning: fsockopen() : unable to connect to https://www.alertpay.com:443 (Unable to find the socket transport "https" - did you forget to enable it...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.