Goodbye, world!'; for (;;) { // @ is used to stop PHP from spamming with error messages if there is no connection if ($client = @socket_accept($socket)) { socket_write($client, "HTTP/1.1 200 OK\r\n" . "Content-length: " . strlen($msg) . "\r\n" . "Content-Type: text/html; charset=UTF-8\r\n\r\n" . $msg); } else usleep(100000); // limits CPU usage by sleeping after doing every request } ?>