Lancement script PHP socket sous wamp
Bonjour,
Différentes discussions ont été postées mais aucune n'a apporté de réponse.
J'ai installé WAMP 2 sous windows 7. J'aimerais exécuter un script php pour un chat sous Flex.
1er problème : lorsque je tape 'php server.php' dans une fenêtre de commande, j'ai l'erreur :
call to undefined function socket_create() at line ...
Voici le code récupéré sur un blog :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
create_connection('localhost',1740);
function create_connection($host,$port)
{
$socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
if (!is_resource($socket)) {
echo 'Unable to create socket: '. socket_strerror(socket_last_error()) . PHP_EOL;
} else {
echo "Socket created.\n";
}
if (!socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1)) {
echo 'Unable to set option on socket: '. socket_strerror(socket_last_error()) . PHP_EOL;
} else {
echo "Set options on socket.\n";
}
if (!socket_bind($socket, $host, $port)) {
echo 'Unable to bind socket: '. socket_strerror(socket_last_error()) . PHP_EOL;
} else {
echo "Socket bound to port $port.\n";
}
if (!socket_listen($socket,SOMAXCONN)) {
echo 'Unable to listen on socket: ' . socket_strerror(socket_last_error());
} else {
echo "Listening on the socket.\n";
} |
J'ai activé l'extension php_socket sous WAMP et décommenter la ligne 'extension=php_sockets.dll' de php.ini dans le dossier d'apache. Mais rien n'y fait :(
Je ne comprends pas d'où vient le problème. Quelqu'un a-t-il une idée, svp ?