I have a PHPWebSocket application, and my server.php has starting part code like that:
$Server = new PHPWebSocket();
$Server->bind('message', 'wsOnMessage');
$Server->bind('open', 'wsOnOpen');
$Server->bind('close', 'wsOnClose');
$Server->wsStartServer('127.0.0.1', 3306);
and PHPLibrary code I have like that:
// server state functions
function wsStartServer($host, $port) {
if (isset($this->wsRead[0])) return false;
if (!$this->wsRead[0] = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) {
return false;
if (!socket_set_option($this->wsRead[0], SOL_SOCKET, SO_REUSEADDR, 1)) {
socket_close($this->wsRead[0]);
return false;
}
if (!socket_bind($this->wsRead[0], $host, $port)) {
socket_close($this->wsRead[0]);
return false;
if (!socket_listen($this->wsRead[0], 10)) {
socket_close($this->wsRead[0]);
return false;
}
When I used this in local computer, then everything worked fine, but when I inserted this on ssh hosting, i have got all the time the same error:
Warning: socket_bind(): unable to bind address [48]: Address already in use in /usr/home/rafaluf/class.PHPWebSocket.php on line 110
Where is the problem here? How do I fix this?