Guest User

Untitled

a guest
Jun 29th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. $host = 'stackoverflow.com';
  2. $ports = array(21, 25, 80, 81, 110, 443, 3306);
  3.  
  4. foreach ($ports as $port)
  5. {
  6. $connection = @fsockopen($host, $port);
  7.  
  8. if (is_resource($connection))
  9. {
  10. echo '<h2>' . $host . ':' . $port . ' ' . '(' . getservbyport($port, 'tcp') . ') is open.</h2>' . "n";
  11.  
  12. fclose($connection);
  13. }
  14.  
  15. else
  16. {
  17. echo '<h2>' . $host . ':' . $port . ' is not responding.</h2>' . "n";
  18. }
  19. }
  20.  
  21. stackoverflow.com:21 is not responding.
  22. stackoverflow.com:25 is not responding.
  23. stackoverflow.com:80 (http) is open.
  24. stackoverflow.com:81 is not responding.
  25. stackoverflow.com:110 is not responding.
  26. stackoverflow.com:443 is not responding.
  27. stackoverflow.com:3306 is not responding.
Add Comment
Please, Sign In to add comment