Jestem poczatkujacy w php. Zamierzam uruchomic sobie skrypt dzialajacy jak prosty serwer, ktory odsyla to, co odbierze. Zainstalowalem sobie WAMPSERVER, i lokalnie mi to dziala. Probuje to odpalic na normalnym serwerze, ale otrzymuja bledy:
Warning: socket_bind() [function.socket-bind]: unable to bind address [99]: Cannot assign requested address in /home/users/kazek/public_html/index.php on line 15
Warning: socket_accept() [function.socket-accept]: unable to accept incoming connection [4]: Interrupted system call in /home/users/kazek/public_html/index.php on line 22
Warning: socket_write() expects parameter 1 to be resource, boolean given in /home/users/kazek/public_html/index.php on line 29
Warning: socket_read() expects parameter 1 to be resource, boolean given in /home/users/kazek/public_html/index.php on line 31
Po czym blad 31 powtarza sie.
Kod znalazlem w manualu:
#!/usr/local/bin/php -q <?php /*pierwsza linia w tym pliku to sciezka do interpretera*/ /* Allow the script to hang around waiting for connections. */ /* Turn on implicit output flushing so we see what we’re getting * as it comes in. */ $address = '10.5.5.3 '; $port = 80; if (($sock = socket_create (AF_INET, SOCK_STREAM, 0)) < 0) { } if (($ret = socket_bind ($sock, $address, $port)) < 0) { } if (($ret = socket_listen ($sock, 5)) < 0) { } do { if (($msgsock = socket_accept($sock)) < 0) { break; } /* Send instructions. */ $msg = "\nWelcome to the PHP Test Server. \n" . "To quit, type 'quit'. To shut down the server type 'shutdown'.\n"; do { if (FALSE === ($buf = socket_read ($msgsock, 2048))) { break 2; } continue; } if ($buf =='quit') { break; } if ($buf == 'shutdown') { socket_close ($msgsock); break 2; } $talkback = "PHP: You said '$buf'.\n"; } while (true); socket_close ($msgsock); } while (true); socket_close ($sock); ?>
Juz w momencie pisania postu jestem swiadom, ze prawdopodobnie nie dostarczam wszystkich potrzebnych wiadomosci do rozwiazania tego problemu. Postaram sie uscislic, jak bede wiedzial, co. Bede wdzieczny za jakiekolwiek porady.
Pozdrawiam