I had tried this code, but i am not understand, the result is craezy....
<?php
$server = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($server, '222.222.222.22'. '4775');
socket_listen($socket);
while (1) {
$connection = socket_accept($server);
socket_write($connection, "Hello there\n", strlen("Hello there\n"));
$input = '';
while ($connection) {
$line = socket_read($connection, 4775, PHP_NORMAL_READ);
//if the client sends QUIT by itself on a line we close the connection.
if ($line == "QUIT\n") {
break;
}
else {
//do something with the data, like fget data from socket
}
}
socket_close($connection);
}
socket_close($server);
?>
ERROR massage:
Warning: socket_bind() [function.socket-bind]: Host lookup failed [0]: The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for. in C:\xampp\htdocs\ujicoba\socket-tcp-ip\looped-server-sockets.php on line 3
Warning: socket_listen() expects parameter 1 to be resource, null given in C:\xampp\htdocs\ujicoba\socket-tcp-ip\looped-server-sockets.php on line 4
Warning: socket_accept() [function.socket-accept]: unable to accept incoming connection [0]: An invalid argument was supplied. in C:\xampp\htdocs\ujicoba\socket-tcp-ip\looped-server-sockets.php on line 7
Warning: socket_write() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\ujicoba\socket-tcp-ip\looped-server-sockets.php on line 9
Warning: socket_close() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\ujicoba\socket-tcp-ip\looped-server-sockets.php on line 26
Warning: socket_accept() [function.socket-accept]: unable to accept incoming connection [0]: An invalid argument was supplied. in C:\xampp\htdocs\ujicoba\socket-tcp-ip\looped-server-sockets.php on line 7
what meaning of this error on looping time?
cause I just wanna try to get some TCP IP data with any TCP IP listener that created in PHP Code, please tell me how to do it ...?