Forum Moderators: coopster
"Warning: socket_bind() unable to bind address [98]: Address already in use in /home/example/public_html/isochat/socket.php on line 179
AIEE -- Couldn't bind!" is the error the php is
// set up the file descriptors and sockets...
// $listenfd only listens for a connection, it doesn't handle anything
// but initial connections, after which the $client array takes over...
$listenfd = socket_create(AF_INET, SOCK_STREAM, 0);
if ($listenfd) {
print 'Listening on port '.PORT.'<br>';
} else {
die('AIEE -- socket died!<br>');
}
//set servers ip here, leave if using a local host
//socket_setopt($listenfd, SOL_SOCKET, SO_REUSEADDR, 1); - old
if (!@socket_setopt($listenfd, SOL_SOCKET, SO_REUSEADDR, 0)) {
echo 'socket_setopt() failed: reason: '.socket_strerror(socket_last_error($listenfd));
exit;
}
if (!socket_bind($listenfd, '0.0.0.0', PORT)){
socket_close($listenfd);
die("AIEE -- Couldn't bind!");
}
socket_listen($listenfd, LISTENQ);
// set up our clients. After listenfd receives a connection,
// the connection is handed off to a $client[]. $maxi is the
// set to the highest client being used, which is somewhat
// unnecessary, but it saves us from checking each and every client
// if only, say, the first two are being used.
//allow spaces for extra users, that will be automatically closed
for ($i = 0; $i < LISTENQ; $i++) {
$client[$i] = null;
}
Please help me with this
[edited by: jatar_k at 3:51 pm (utc) on June 2, 2005]
[edit reason] shortened code and removed url [/edit]
The problem is here...
if (!socket_bind($listenfd, '0.0.0.0', PORT)){
socket_close($listenfd);
die("AIEE -- Couldn't bind!");
}
The socket_bind funciton is failing.
A possible solution is in the manual in the last user comment
[php.net...]
Tim