Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #!/usr/bin/php
  2.  
  3. <?php
  4. # zmienne predefiniowane -------------------------------------------
  5. $host = "10.6.11.24";
  6. $port = 12345;
  7.  
  8. # tworzymy gniazdo -------------------------------------------------
  9. if( ! ( $server = stream_socket_server( "tcp://$host:$port", $errno, $errstr ) ) ){
  10. print "stream_socket_server(): $errstr\n";
  11. exit( 1 );
  12. }
  13.  
  14. # obslugujemy kolejnych klientow, jak tylko sie podlacza -----------
  15. while( $client = stream_socket_accept( $server ) ) {
  16. # wyswietlamy informacje o klientach - - - - - - - - - - - - - -
  17. $str = stream_socket_get_name( $client, 1 );
  18. list( $addr, $port ) = split( ':', $str );
  19.  
  20. print "Addres: $addr Port: $port\n";
  21. # przekazujemy informacje o obecnym czasie - - - - - - - - - - -
  22. fwrite( $client, "Current time: " . time() . "\n");
  23. fclose( $client );
  24. }
  25. #-------------------------------------------------------------------
  26. fclose( $server );
  27. #===================================================================
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement