PHP function used to open (Internet or Unix domain) sockets connections.
Questions tagged [fsockopen]
382 questions
2
votes
1 answer
PHP listen to unix socket
So in short I'm trying to get a PHP script to listen for requests over unix sockets and send it a request from another PHP script.
I have configured PHP-FPM as such:
[a]
; Unix user/group of processes
user = www
group = www
listen =…

FireLeopard
- 314
- 4
- 18
2
votes
0 answers
Downloading large files using fsockopen() and fgets()
For a client of mine, I am working on a API connection to DirectAdmin from his own system, for multiple purposes. One is managing backups. When a backup is created, it should also be available for download.
However, I can not get this to work. I am…

Jan Willem
- 1,280
- 1
- 9
- 9
2
votes
1 answer
Make loops in php
I am actually making a script to check whether game server is online or offline!
As of now the script i have made which does not check the server every 20 minutes.
I want the script to check whether the server is online or offline and out put the…

karansanjeev
- 59
- 6
2
votes
1 answer
PHP Share fsockopen between functions on page
Is it possible to open a socket with one function and send commands to that socket with another function all from the same page ?
When I try this I get: Warning: fputs(): supplied argument is not a valid stream resource
This is the code I'm…

Tom
- 1,436
- 24
- 50
2
votes
1 answer
Yii serve do nothing when I try to run it. (fsockopen(): unable to connect)
I was trying to get started with Yii2 framework. As described in documentation i did
$composer global require "fxp/composer-asset-plugin:~1.1.1"
$composer create-project --prefer-dist yiisoft/yii2-app-basic yii2-test
then I cd yii2-test and run…

Nikita U.
- 3,540
- 1
- 28
- 37
2
votes
0 answers
WAMP PHP 5.6 fsockopen returns nothing
I have a strange thing, fsockopen works fine with PHP 5.5 on WAMP, but fails with PHP 5.6 (also WAMP, same server).
I am using a library, there is this code:
$url = parse_url($uri);
if ('https' == $url['scheme']) {
$host =…

Dovis
- 167
- 2
- 12
2
votes
2 answers
Rare strange readings with fsockopen
I'm using fsockopen on a small cronjob to read and parse feeds on different servers. For the most past, this works very well. Yet on some servers, I get very weird lines in the response, like this:
en
…

Ineluki
- 118
- 1
- 7
2
votes
1 answer
PHP fsockopen doesn't work with domain names
I have the following script:
$con = @fsockopen('mx.mydomain.com', 587, $errno, $errstr, 10);
if(empty($con)) echo "Not connected: ".$errno." - ".$errstr;
else echo "Connected!";
It's returned:
Not connected: 110 - Connection timed out
Occurs using…

Diogo Braga
- 183
- 1
- 8
2
votes
1 answer
PHP ipv6 support in fsockopen()
We are using PHP and fsockopen() to check if a host is available. It works great for standard ipv4 addresses, but recently we started adding ipv6 addresses and it fails. According to the PHP documentation for fsockopen() we simply just need to…

Justin
- 42,716
- 77
- 201
- 296
2
votes
2 answers
fsockopen seems very slow
Why is this fsockopen so slow compared to the same request from a browser?
php fsockopen: 0.254 secs
browser: 0.070 secs
fsockopen request
$time = microtime(true);
if($fp = fsockopen('ssl://domain.com', 443, $errno, $errstr, 20)){
echo…

clarkk
- 27,151
- 72
- 200
- 340
2
votes
1 answer
fget over server, how to read until end of current transmission?
I'm writing a tool that connects to a server, sends request, read response, and send other commands.
The problem is that the response the server send can vary in terms of lines (it's always at least one line, but can be 3, 5 lines), and he can send…

Cyril N.
- 38,875
- 36
- 142
- 243
2
votes
1 answer
fsockopen, cURL, and file_get_contents are slow
I have no clue why... But all the methods I listed in the title are slow. They take about 10 seconds, yet when I visit the sites, they load immediately. Here is one of my codes that uses file_get_conents:

user3597487
- 41
- 2
- 4
2
votes
1 answer
fsockopen causes FATAL error when host is unreachable - "unable to connect to"
When I call fsockopen to an unreachable IP address, PHP stops execution with FATAL ERROR, as it is intended to do. But it's normal situation for me, that a host is unreachable. Is there a way, how to prevent stopping the php even in case of the…

user3523426
- 836
- 3
- 11
- 26
2
votes
1 answer
how to detect closed socket in PHP (FIN flag)?
Here is my problem:
FIN and RST packets detect correctly only when there is NO socket_set_nonblock option for socket-functions or stream_set_blocking (for fsockopen) is set to FALSE.
Is there a way in PHP to detect manually when socket closes?

zogby
- 462
- 4
- 15
2
votes
2 answers
Why does fsockopen have performance problems and not fopen when sending a POST request in PHP?
I have tried two different implementations for simulating POSTing a form. One uses fsockopen (example here: http://www.faqts.com/knowledge_base/view.phtml/aid/7962) and the other uses fopen (example here:…

Steven Oxley
- 6,563
- 6
- 43
- 55