Socket how to die if connection broken

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi I have a socket connection like so..

$sourceip = '84.234.18.16'; // ip you want to bind to

$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($sock, $sourceip);
socket_connect($sock, 'dac.nic.uk', 2043);

if ($socket === false) {
   $errorcode = socket_last_error();
   $errormsg = socket_strerror($errorcode);
die("Couldn't create socket: [$errorcode] $errormsg");
}


But if the socket connection gets broken it creates an error msg
Warning: socket_write(): unable to write to socket [32]: Broken pipe in
Warning: socket_write(): unable to write to socket [32]: Broken pipe in
Warning: socket_write(): unable to write to socket [32]: Broken pipe in

That spills out for thousands and thousands of lines.

What would I need for the script to die if the connection gets broken.

Thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux