Solution socket error 10060 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

When you are programming in php within windows os and you received  HTTP ERROR: Couldn't open socket connection to server. Error (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

The Reason and solution for socket error 10060 and solution is given bellow

A.Windows firewall blocking connection:

       The most probable reason for socket connection not working in windows os is because of the firewall of windows os does not allow the socket network communication. IN Windows 7 and Vista you can solved the socket error using Opening port for communicate and allow all access to this port. 

Steps to open port in windows 7: 

 Go to Control Panel-->Security and Settings-->Windows Firewall

  Advanced Settings-->Inbound Rules-->New rule

 Select port-->Click Next-->Select as TCP and Add Your Server Port
    
 For Example For PHP it is 8080 or 80 port number and for mail service it is port 25 .
  Do the same   procedure for the outbound Rules.

B.Your DNS Name is not resolved properly.

If Your DNS name is not resolved properlly then this error might occure.In case of local host If Your localhost is not Resolved properlly then you can try 127.0.0.1 this might work for you. example:   http://127.0.0.1:80/webservice/nusoap/server/server.php?wsdl


C. Your Script might not properlly response because of Timeout of socket connection.

    In this case you can inscrese timeout parameter for connecting socket.

D. In PHP socket extension must be enabled 

    In this case check socket extensuion in php ini file just go to php installation directory and open php.ini.
    uncomment extension=php_sockets.dll  line.

Buy Me a Beer-If you are like this post

 If you does not have paypal account create free account create account

PHP convert file to string

Here you will find a  free php scripts, php resources, php tutorials, web resources , jquery


Here is solution how easily you can convert any file into string


For web development if web developer want to store file contents or transfer file contents, In php the file can easily converted to string and vice versa.

Using Base64 encode


$filepath="full file path"; // example c:\images\mypic.jpg

$fileString=base64_encode(addslashes(fread(fopen($filepath, "r"), filesize($filepath))));



Using Base64 Decode


$decodedData=base64_decode($fileString);

$fp = fopen('newFileName', 'w');
fwrite($fp, $decodedData);
fclose($fp);

Buy Me a Beer-If you are like this post

 If you does not have paypal account create free account create account