Now I read the instructions and everything, and everything works fine except for the following problem: For some reason, when i entered to the file server (SERVER.php) I get the following error:
Warning: socket_bind() [function.socket-bind]: Host lookup failed [-10003]: Unknown server error in /home/a9889405/public_html/SERVER/api.php on line 772
Here is the current section from the file itself:
* Look at "line 772"
// ----- sock_listen -----
function sock_listen()
{
$this->log("Main socket listen on port {$this->sock_port}", 1);
if (!($this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)))
{
$this->log("Error in TServer::socket_connect - couldn't create socket", 1);
return $this->sock = false;
}
if (!socket_setopt($this->sock, SOL_SOCKET, SO_REUSEADDR, 1))
$this->log("Error in TServer::socket_connect - couldn't set SO_REUSEADDR", 1);
if (!socket_set_nonblock($this->sock))
$this->log("Error in TServer::socket_connect - couldn't set non-blocking mode", 1);
if (!socket_bind($this->sock, $this->sock_ip, $this->sock_port)) // ----- line 772 -----------
{
$this->log("Error in TServer::socket_connect - couldn't bind socket", 1);
return $this->sock = false;
}
if (!socket_listen($this->sock, 16))
{
$this->log("Error in TServer::socket_connect - couldn't listen on socket", 1);
return $this->sock = false;
}
return true;
}
If this is important, here's the instructions file:
Java Chat Installation Guide
1. Overview:
The software includes: a) Java/JavaScript client applicaton. b) Server-side script that connects client applications.
Assign "ServerURL" variable to the URL of the server-side script, "host" variable to your domain name, and "port" variable to the port number you specified in the init.php file.
5. Integrating the software with your membership system.
5.1. Open init.php file and find "Custom Functions" section. This section contains "Check Password" and "Check if User Exists" subsections.
5.2. "Check Password" subsection contains 2 versions of check_password function that looks like this:
function check_password($user, $pass) { <body of the function> }
This function is called by the server-side script to validate login information against membership system.
5.2.1. The first version of check_password function (default) will validate any non-empty username. You can use this option to test the software.
5.2.2. The second version of check_password function will check username and password against MySQL database. To use this function, find out the name of MySQL table and the names of the fields in this table that contain login information. Assign the variables $table_name, $username_field and $password_field in the body of the function to the name of the table and the names of the fields.
5.3. "Check if User Exists" subsection contains 2 versions of check_userexists function that looks like this:
function check_userexists($user) { <body of the function> }
This function is called by the server-side script to check if the user with a given username exists.
5.3.1. The first version of check_userexists function (default) will validate any non-empty username.
5.3.2. The second version of check_userexists function will check username against MySQL database.
5.4. After editing the functions and uploading init.php to your server, restart the server-side script. You can do it by sending "shut down" message from the client application. If you did not configure the server-side script to restart automatically, you need to open server.php file in your browser.
6. Purchasing the software (Advanced version only):
To use the software on your website, you need to purchase the site license:
6.1. One site license = $10.
6.2. One site license + installation assistance = $40.
7. Known problems:
7.1. Host does not allow executing daemons (see http://www.google.com/search?q=define:daemon for definition). Host has execution time limits. Try to find dedicated or semi-dedicated hosting plan.
7.2. Error message: "Fatal error: Call to undefined function ..." Most likely, your host does not have Sockets extension for PHP. Contact your hosting provider.
7.3. The server-side script starts without errors, but client application can not connect it. Most likely, socket connection is blocked by the firewall running on your server. Contact your hosting provider
And if it matters, I get only one more error:
Warning: set_time_limit() has been disabled for security reasons in /home/a9889405/public_html/SERVER/server.php on line 27
Royush
Member
2 Points
6 Posts
A little problem with installing Chat - "Socket bind"
Apr 02, 2012 12:03 PM|LINK
Hello
* The server is host on the following company: http://www.000webhost.com / features
I try to install the following Chat from: http://www.php-development.ru/products/java-chat
Now I read the instructions and everything, and everything works fine except for the following problem: For some reason, when i entered to the file server (SERVER.php) I get the following error:
Here is the current section from the file itself:
* Look at "line 772"
// ----- sock_listen ----- function sock_listen() { $this->log("Main socket listen on port {$this->sock_port}", 1); if (!($this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) { $this->log("Error in TServer::socket_connect - couldn't create socket", 1); return $this->sock = false; } if (!socket_setopt($this->sock, SOL_SOCKET, SO_REUSEADDR, 1)) $this->log("Error in TServer::socket_connect - couldn't set SO_REUSEADDR", 1); if (!socket_set_nonblock($this->sock)) $this->log("Error in TServer::socket_connect - couldn't set non-blocking mode", 1); if (!socket_bind($this->sock, $this->sock_ip, $this->sock_port)) // ----- line 772 ----------- { $this->log("Error in TServer::socket_connect - couldn't bind socket", 1); return $this->sock = false; } if (!socket_listen($this->sock, 16)) { $this->log("Error in TServer::socket_connect - couldn't listen on socket", 1); return $this->sock = false; } return true; }If this is important, here's the instructions file:
And if it matters, I get only one more error:
Function:
But I think it has nothing, and its not matter.