z portu serwera i zapisaniem jej w pliku txt. Poczatek skryptu wyglada tak:
Kod
// Set the ip and port we will listen on
$host = '127.0.0.1';
$port = 20000;
set_time_limit(0);
// create low level socket
if(!$socket=socket_create(AF_INET,SOCK_STREAM,0)){
trigger_error('Error creating new socket',E_USER_ERROR);
}
# reuse socket tweak
if (!socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1)) {
echo socket_strerror(socket_last_error($socket));
exit;
}
// tie up socket to TCP port
if(!socket_bind($socket,$host,$port)){
trigger_error('Error binding socket to TCP host:'.$host.', port:'.$port.'',E_USER_ERROR);
}
// begin listening connections
if(!socket_listen($socket)){
trigger_error('Error listening socket connections',E_USER_ERROR);
}
// create communication socket
if(!$comSocket=socket_accept($socket)){
trigger_error('Error creating communication socket',E_USER_ERROR);
}
// read socket input
$socketInput=socket_read($comSocket,1024);
//write data to file
....
// close sockets
socket_close($comSocket);
socket_close($socket);
Kod
PHP Warning: set_time_limit(): Cannot set time limit
PHP Warning: socket_bind() unable to bind address [98]: Address already in use
Could not bind to address
PHP Warning: socket_bind() unable to bind address [98]: Address already in use
Could not bind to address
Problem pojawia sie bez wzgledu na numer portu. Nawet jesli port nie jest zadeklarowany
do nasluchu w httpd.conf. Po prostu od razu okazuje sie 'zajety'.
Prosze o podpowiedz gdzie moze byc przyczyna problemu. Ewentualnie gdzie jest blad / braki w kodzie.
Wiktor