int pid_listen ( int $pid, [ int $backlog = 1] )
pid_listen() waits for and accepts a TCP connection from a foreign client.
This function is non-blocking so it returns immediately.
※ available F/W version : all
Returns 0 on success, PHP error on error
<?php
$pid = pid_open("/mmap/tcp0"); // open TCP0
$port = 1470; // local port number to accept
pid_bind($pid, "", $port);
pid_listen($pid); // wait for a TCP connection from the foreign host
echo "listen...\r\n";
do
{
$state = pid_ioctl($pid, "get state");
}while(($state != TCP_CONNECTED) && ($state != TCP_CLOSED));
if($state == TCP_CONNECTED) echo "TCP connected\r\n";
else if($state == TCP_CLOSED) echo "TCP connection failed\r\n";
while(1);
?>
pid_open() / pid_close() / pid_ioctl() / pid_read() / pid_write() / pid_recv() / pid_send() / pid_connect()
None