<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Th30z - Coding on the Fly &#187; PHP</title>
	<atom:link href="http://th30z.netsons.org/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://th30z.netsons.org</link>
	<description>Matteo Bertozzi, Objective-C, Cocoa, C, C++, Qt4, iPhone, Mac OS X, Open Moko, Matteo Bertozzi Development</description>
	<lastBuildDate>Sun, 22 Nov 2009 09:47:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>[TIP] Test TCP Port with PHP</title>
		<link>http://th30z.netsons.org/2008/09/tip-test-tcp-port-with-php/</link>
		<comments>http://th30z.netsons.org/2008/09/tip-test-tcp-port-with-php/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 07:19:22 +0000</pubDate>
		<dc:creator>Matteo Bertozzi</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://th30z.netsons.org/?p=184</guid>
		<description><![CDATA[I need to test if specified TCP Port on specified Host is opened or Not, and i need to do it from a Web Service&#8230; This is my Solution a simple &#8220;ping&#8221; method written in PHP.

function qPing ($host, $port, $timeout = 5) {
    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    if [...]]]></description>
			<content:encoded><![CDATA[<p>I need to test if specified TCP Port on specified Host is opened or Not, and i need to do it from a Web Service&#8230; This is my Solution a simple &#8220;ping&#8221; method written in PHP.</p>
<pre>
function qPing ($host, $port, $timeout = 5) {
    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    if ($socket === false) return(1);

    if (!socket_set_nonblock($socket))
        return(2);

    $time = time();
    while (!@socket_connect($socket, $host, $port)) {
        $err = socket_last_error($socket);
        if ($err == 115 || $err == 114) {
            if ((time() - $time) >= $timeout) {
                socket_close($socket);
                return(3);    # Connection timed out.
            }
            usleep(500);
            continue;
        }
        echo $err . ' ' . socket_strerror($err) . "\n";
        return(4);
    }

    socket_close($socket);
    return(0);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://th30z.netsons.org/2008/09/tip-test-tcp-port-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
