pid_listen()


int pid_listen ( int $pid, [ int $backlog = 1] )

Description

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

Parameters

Return values

Returns 0 on success, PHP error on error

Example

<?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);
?>

See also

pid_open() / pid_close() / pid_ioctl() / pid_read() / pid_write() / pid_recv() / pid_send() / pid_connect()

Remarks

None