Switch to full style
:read: Start PHP with us. Includes topics to help you in php
Post a reply

Open socket and read

Tue Oct 28, 2008 2:27 pm

Code:
<?php
   
// Establish a port 80 connection with www.example.com
   
$http = fsockopen("www.codemiles.com",80);

   
// Send a request to the server
   
$req = "GET / HTTP/1.1\r\n";
   
$req .= "Host: www.codemiles.com\r\n";
   
$req .= "Connection: Close\r\n\r\n";
   
fputs($http, $req);

   
// Output the request results
   
while(!feof($http)) {
      echo
fgets($http, 1024);
   }

   
// Close the connection
   
fclose($http);

?>




Post a reply
  Related Posts  to : Open socket and read
 TCP socket in C++     -  
 java.net.SocketTimeoutException: Socket operation timed out     -  
 Client-Server-Data-datagram socket UDP protocol     -  
 Which open-source CMS is the best?     -  
 Open in a new window help     -  
 Open other application from java     -  
 Unable to open OST file in C# [.net]     -  
 Open a link in a new window?     -  
 Google adwords open in new window     -  
 How to open http connection using j2me     -  

Topic Tags

PHP Networking