I would like to ask what is something missing or what is wrong with my fsockopen() in codeigneter. Ive been searching for fives days now and I couldn
t figure out what is wrong since others who got the same error with mine we are on a different scenario. While them are for sending emails me is to get the Server Status if online or offline.
I`ve been creating a Online Games Web Templater were it can fetch/display data from Game Remote Server to webhosting. I was able to connect MSSQL to a remote server but the fsockeopne() does not work.
Helper.php Codes
function getServerConnection($ip, $port) {
$sockres = @fsockopen($ip, $port, $errno, $errstr, 0.01);
if (!$sockres) {
return '<b class="text-danger">OFFLINE</b>';
} else {
@fclose($sockres);
return '<b class="text-success">ONLINE</b>';
}
}
View Codes
<p class="m-b-10">
<span class="left">LOGIN: <?php echo getServerConnection($server_settings->server_ip, $server_settings->login_port) ?></span>
<span class="float-right">WORLD: <?php echo getServerConnection($server_settings->server_ip, $server_settings->server_port) ?></span></p>
Var_dum $sockres and error
A PHP Error was encountered Severity: Warning Message: fsockopen(): unable to connect to 192.168.1.1:80 (Connection timed out) - JUST DUMMY IP. IT HAS A REAL REMOTE IP Filename: helpers/myhelper_helper.php
bool(false) int(110) string(20) "Connection timed out"
The allow_url_fopen = on and remote server firewall has been configure already
Thank you in advance :) sorry for my English I am not really good on this.
I was able to figureout this error it was because I am using wrong port. and make sure you configure correctly into your windows firewall. And try to use this one to check the port https://ping.eu/port-chk/