When your shared server unexpectedly closes all ports after a DDoS (distributed denial of service) attack, and you need port 80 open for various API or AdSense connections, what do you do? First, try customer support, and then consider disabling certain plug-ins, but if these steps fail you can still find a workaround while the hosting provider works on the issue. One potential result of the closed ports is a failure of PHP function fsockopen() because of firewall restrictions on the outgoing connections. These restrictions are intended to prevent a prolonged attack, but may cause a delay in page-loads and an error message on individual Wordpress posts. In this case, Wordpress displays the message:
Warning: fsockopen() [function.fsockopen]: unable to connect to pagead2.googlesyndication.com:80 (Connection timed out) in /home6/tkbbblog/public_html/wp-includes/class-snoopy.php on line 1142 /wp-includes/class-snoopy.php
at the beginning of single posts, but not on the index page, although AdSense ads appear on both sections. Pages may take noticeably longer to load, resulting in fewer visitors to the site.
By default, Wordpress sets the socket connection to timeout after 30 seconds. This means that a visitor will have to wait an eternity for a post to load. I hate waiting 5 seconds, let alone 30, for a site to load.
The resulting workaround requires a quick edit of the class-snoopy.php file. Find the file in the public_html/wp-includes/ directory and open it in your favorite editing program or interface. Find the line (usually 112) that says:
var $_fp_timeout = 30; // timeout for socket connection
and change the timeout to something considerably smaller (2 seconds should work fine). Now, posts will load much quicker, but still will display the fsockopen() warning.



























