All pastes #510138 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-05-25 19:34 UTC
rendered paste body
<?php

		echo "connecting without ssl\n";
		$sock = fsockopen("euserv.de", 80,$errno, $errstr, 30);
		if($sock) echo "connected;\n";
		socket_set_blocking($sock, 0);
		$count=0;
		while (!feof($sock))
		{		
			echo "loop: ".$count."\n";
			fgets($sock, 4096);
			if($count==10) break;
			$count++;
		}
		fclose($sock);
		unset($sock);
		if($count==10) echo "stream_set_blocking(\$sock, 0); seems to work without ssl!\n"; else echo "it is not working :(\n";
		
		//now with ssl:
		echo "connecting with ssl\n";
		$sock = fsockopen("ssl://euserv.de", 443,$errno, $errstr, 30);
		stream_set_blocking($sock, 0);
		$count=0;
		while (!feof($sock))
		{		
			echo "loop: ".$count."\n";
			fgets($sock, 4096);
			if($count==10) break;
			$count++;
		}
		fclose($sock);
		unset($sock);
		if($count==10) echo "stream_set_blocking(\$sock, 0); seems to work with ssl!\n"; else echo "it is not working :(\n";
?>