Discussione:
problema con i socket... che frustrazione, help!!!
(troppo vecchio per rispondere)
jason vorhees
2004-11-08 16:02:54 UTC
Permalink
ciao a tutti,
propongo il mio spinoso problema sperando che qualche esperto riesca a
metterci una pezza perchè non ne vengo a capo! Sto cercando di capire
come funzionano i socket e ho preso un esempio base da un tutorial.
Il mio ambiente di sviluppo è Apache/1.3.27 (Win32) PHP/4.3.4

L'errore che ottengo il seguente:
"Warning: socket_bind() unable to bind address [10048]: Di norma è
consentito un solo utilizzo di ogni indirizzo di socket
(protocollo/indirizzo di rete/porta). in c:\programmi\apache
group\apache\htdocs\test\socket\exercise.php3 on line 12
Could not bind to socket"
Sembrerebbe esserci un altro servizio che sta utilizzando quella porta:
ma allora come facco a determinare quella giusta?
Grazie mille!!

<?
// set some variables
$host = "127.0.0.1";
$port = 1135;

set_time_limit(0);

// create socket (TCP socket)
$socket = socket_create(AF_INET, SOCK_STREAM, 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);
?>
Setec Astronomy
2004-11-08 17:10:44 UTC
Permalink
Post by jason vorhees
"Warning: socket_bind() unable to bind address [10048]: Di norma è
consentito un solo utilizzo di ogni indirizzo di socket
(protocollo/indirizzo di rete/porta). in c:\programmi\apache
group\apache\htdocs\test\socket\exercise.php3 on line 12 Could not
bind to socket" Sembrerebbe esserci un altro servizio che sta
utilizzando quella porta: ma allora come facco a determinare quella
giusta?
Non e' che hai un firewall in modalita' stealth attivo?
--
I am what I am, I do what I can
Sei un newbie? Leggi questo http://url.repository.biz/go/3C
Vuoi supportarmi? http://url.repository.biz/go/3E
Do. Or do not. There is not try.
jason vorhees
2004-11-08 17:42:24 UTC
Permalink
Post by Setec Astronomy
Post by jason vorhees
"Warning: socket_bind() unable to bind address [10048]: Di norma è
consentito un solo utilizzo di ogni indirizzo di socket
(protocollo/indirizzo di rete/porta). in c:\programmi\apache
group\apache\htdocs\test\socket\exercise.php3 on line 12 Could not
bind to socket" Sembrerebbe esserci un altro servizio che sta
utilizzando quella porta: ma allora come facco a determinare quella
giusta?
Non e' che hai un firewall in modalita' stealth attivo?
il firewall di win xp è disabilitato... rimane Sygate Personal Firewall 5.6
Provo disattivando quest'ultimo?

Beh... certo che potrei testare direttamente anche senza chiedere :-)
jason vorhees
2004-11-08 17:58:31 UTC
Permalink
Post by jason vorhees
Post by Setec Astronomy
Post by jason vorhees
"Warning: socket_bind() unable to bind address [10048]: Di norma è
consentito un solo utilizzo di ogni indirizzo di socket
(protocollo/indirizzo di rete/porta). in c:\programmi\apache
group\apache\htdocs\test\socket\exercise.php3 on line 12 Could not
bind to socket" Sembrerebbe esserci un altro servizio che sta
utilizzando quella porta: ma allora come facco a determinare quella
giusta?
Non e' che hai un firewall in modalita' stealth attivo?
il firewall di win xp è disabilitato... rimane Sygate Personal Firewall 5.6
Provo disattivando quest'ultimo?
Beh... certo che potrei testare direttamente anche senza chiedere :-)
Dunque, ho provato ma niente.... in pratica lo script mi gira
all'infinito......
Con netstat -a vedo la situazione delle porte: posso (forse dovrei se
studiassi maggiormente) capire qualcosa di più?

Grazie mille per la disponibilità.
Jay Jay
2004-11-08 20:30:08 UTC
Permalink
Post by jason vorhees
Dunque, ho provato ma niente.... in pratica lo script mi gira
all'infinito......
Con netstat -a vedo la situazione delle porte: posso (forse dovrei se
studiassi maggiormente) capire qualcosa di più?
Se la porta in ascolto e' gia' usata e' normale come
comportamento (*STATO LISTENING*).
Prova una altra porta (dipende da cosa devi fare).
Il socket potrebbe anche rimanere in ascolto se il tuo script viene
terminato senza chiudere il socket (poi andra in timeout,
prova restart apache).

Loading...