0

I hope this is not a duplicate but I could not find a laravel IP address ping..., I have this: Ping::check('http://example.com'); which returns 200 if website is alive or 0 if not, but it doesnt work on DNS or IPs...

For example, the DNS is: server.sols-rpg.com:7777 and it also has a port as you can see 7777, it is a SAMP server, if I go to a DNS lookup, some will also tell me that it is online and running, or some will just give me its IP, but still, how can I ping it?

Krok
  • 11
  • 1
  • 1
  • 4
    There are no ports with `ping`. It's ICMP, which has [no such thing](https://serverfault.com/questions/309357/ping-a-specific-port). You could try [`fsockopen`](http://php.net/manual/en/function.fsockopen.php) to see if a port is open. – ceejayoz Sep 28 '17 at 14:17
  • check this see if it helps https://stackoverflow.com/questions/13283674/how-to-ping-ip-addresses-in-php-and-give-results – Hanlin Wang Sep 28 '17 at 14:17
  • @HanlinWang But how can I do this with laravel, there is no `exec("ping -n 3 $ip", $output, $status);` for laravel – Krok Sep 28 '17 at 14:22
  • 1
    that's a php function, it exists in every php application, laravel is a php application too, so you can use it directly – Hanlin Wang Sep 28 '17 at 14:22
  • @Krok Laravel is a PHP framework. You can use literally any PHP code in it. There doesn't have to be a built-in Laravel command to do so. – ceejayoz Sep 28 '17 at 14:23
  • Oh, I forgot to add a `;` and it told me that it was unexpected. – Krok Sep 28 '17 at 14:29
  • Please avoid use of exec. All together. There is alternatives – Daryl Gill Sep 28 '17 at 15:28

0 Answers0