I have a Jelastic
environment which runs a PHP
socket
server that receives messages from GPS devices (which communicate via GPRS) and stores what it receives. I'm using the SocketServer.class.php class created by Navarr Barnier (link here). It's a pretty simple application as you can see:
<?php
require_once("SocketServer.class.php");
$server = new SocketServer("<server address>",20490);
$server->max_clients = 10;
$server->hook("CONNECT","handle_connect");
$server->hook("INPUT","handle_input");
$GLOBALS['conexao'] = mysql_connect('<mysql_address>', 'root', '<mysql_password>');
$GLOBALS['selected'] = mysql_select_db('<database>',$GLOBALS['conexao']);
$server->infinite_loop();
function handle_connect($server,$client,$input)
{
SocketServer::socket_write_smart($client->socket,"OK!");
}
function handle_input($server,$client,$input)
{
//echo "\nInput = ".$input;
//$query = "INSERT INTO `messages`(`message`) VALUES (\"".$input."\")";
mysql_query("INSERT INTO `messages`(`message`) VALUES ('".$input."')");
}
This code gives Issue Binding as the output, i.e it cannot create a socket at given IP:port and other IP:ports.
Actually, I've tried it all:
$server = new SocketServer("localhost",20490);
$server = new SocketServer("127.0.0.1",20490);
$server = new SocketServer("0.0.0.0",20490);
$server = new SocketServer("0",20490);
$server = new SocketServer("<server_dns>",20490);
$server = new SocketServer("<server_public_ip>",20490);
And more... All gives "Issue Binding". Any ideas on how to setup this basic socket server?