Posted By

miziomon on 11/17/06


Tagged

socket client


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

tylerhall
vali29


Php Socket Client


 / Published in: PHP
 

  1. <?php
  2. $host="localhost" ;
  3. $port=12345;
  4. $timeout=30;
  5. $sk=fsockopen($host,$port,$errnum,$errstr,$timeout) ;
  6. if (!is_resource($sk)) {
  7. exit("connection fail: ".$errnum." ".$errstr) ;
  8. } else {
  9. fputs($sk, "hello world") ;
  10. $dati="" ;
  11. while (!feof($sk)) {
  12. $dati.= fgets ($sk, 1024);
  13. }
  14. }
  15. fclose($sk) ;
  16. echo($dati) ;
  17. ?>

Report this snippet  

You need to login to post a comment.