utrecht
28-10-2004, 09:26
ciao a tutti,
sto facendo un po' di esercizi (sono proprio all'inizio :( ) utilizzando i socket ma mi sono bloccato su questo errore e non riesco più a procedere
oltre.
Cosa significa questo warning?
Grazie
Warning: socket_listen() unable to listen on socket [10045]: Operazione richiesta non supportata per il tipo di oggetto indicato. in
c:\programmi\apache group\apache\htdocs\test\socket\exercise.php3 on line 20
Could not set up socket listener
Ecco il codice
---
<?
// set some variables
$host = "127.0.0.1";
$port = 1234;
// don't timeout!
set_time_limit(0);
// create socket (TCP socket)
/*$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not
create socket\n");*/
//If you wanted to create a UDP socket, you could use the following line
of code instead
$socket = socket_create(AF_INET, SOCK_DGRAM, 0) or die("Could not create
socket\n");
// bind socket to port
$result = socket_bind($socket, $host, $port) or die("Could not bind to
socket\n");
// start listening for connections
$result = socket_listen($socket, 1) or die("Could not set up socket
listener\n");
// accept incoming connections
// spawn another socket to handle communication
$spawn = socket_accept($socket) or die("Could not accept incoming
connection\n");
// read client input
$input = socket_read($spawn, 1024) or die("Could not read input\n");
// clean up input string
$input = trim($input);
// reverse client input and send back
$output = strrev($input) . "\n";
socket_write($spawn, $output, strlen ($output)) or die("Could not write
output\n");
// close sockets
socket_close($spawn);
socket_close($socket);
?>
Grazie!!
sto facendo un po' di esercizi (sono proprio all'inizio :( ) utilizzando i socket ma mi sono bloccato su questo errore e non riesco più a procedere
oltre.
Cosa significa questo warning?
Grazie
Warning: socket_listen() unable to listen on socket [10045]: Operazione richiesta non supportata per il tipo di oggetto indicato. in
c:\programmi\apache group\apache\htdocs\test\socket\exercise.php3 on line 20
Could not set up socket listener
Ecco il codice
---
<?
// set some variables
$host = "127.0.0.1";
$port = 1234;
// don't timeout!
set_time_limit(0);
// create socket (TCP socket)
/*$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not
create socket\n");*/
//If you wanted to create a UDP socket, you could use the following line
of code instead
$socket = socket_create(AF_INET, SOCK_DGRAM, 0) or die("Could not create
socket\n");
// bind socket to port
$result = socket_bind($socket, $host, $port) or die("Could not bind to
socket\n");
// start listening for connections
$result = socket_listen($socket, 1) or die("Could not set up socket
listener\n");
// accept incoming connections
// spawn another socket to handle communication
$spawn = socket_accept($socket) or die("Could not accept incoming
connection\n");
// read client input
$input = socket_read($spawn, 1024) or die("Could not read input\n");
// clean up input string
$input = trim($input);
// reverse client input and send back
$output = strrev($input) . "\n";
socket_write($spawn, $output, strlen ($output)) or die("Could not write
output\n");
// close sockets
socket_close($spawn);
socket_close($socket);
?>
Grazie!!