Question:How do you get a socket connection in php? 

Answer The fsocketopen() function establishes a connection to the resource designated by target on port.

Prototype:

resource fsockopen( string target, int port [, int erron [, string errsting [, float timeout]]])

Example:

<?php
   $http=fsockopen("www.example.com",80);
 
   $req="GET / HTTP/1.1\r\n";
   $req.="Host: www.example.com\r\n";
   $req.="Connection: Close\r\n\r\n";

  fputs($http,$req);
 
  while(!feof($http)){

      echo fgets($http,1024);

   }
fclose($http);
 
?> 


Deprecated: html_entity_decode(): Passing null to parameter #1 ($string) of type string is deprecated in D:\webserver\www\vcampusbd.com\answers\column_answer_two.php on line 128
+ Report
Total Preview: 768
How do you get a socket connection in php?
Copyright © 2024. Powered by Intellect Software Ltd