pid_connect()


int pid_connect ( int $pid, string $addr, int $port )

Description

pid_connect() attempts to establish a TCP connection to the specified IP address and port number
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
$addr = "10.3.0.10";  // IP address to connect to
$port = 1470;  // peer host’s service port number
pid_connect($pid, $addr, $port); // trying to TCP connect to the specified host/port
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_read() / pid_write() / pid_ioctl() / pid_recv() / pid_send() / pid_listen()

Remarks

None