Results 1 to 9 of 9
  1. #1

    Network Programming with PHP question

    In the future I might need to create a script that tallies the domains on a shared IP and pings them..among other things. I was just wondering if this is possible with PHP or do I need to use shell scripting?
    Optimize Your Web Hosting Operation - Empire Consultant

  2. #2
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    3,103
    PHP can manipulate raw sockets so yes, you could implement ICMP communication in PHP.

  3. #3
    Join Date
    Mar 2007
    Location
    UK
    Posts
    89
    Quote Originally Posted by sasha View Post
    PHP can manipulate raw sockets so yes, you could implement ICMP communication in PHP.
    For example:
    http://www.planet-source-code.com/vb...txtCodeId=1786

  4. #4
    Cool thanks!

    If you guys know of any good sites with regards to network programming with php please let me know.
    Optimize Your Web Hosting Operation - Empire Consultant

  5. #5
    Join Date
    Dec 2007
    Location
    Lebanon
    Posts
    413
    I think you will need some shell scripting through php though!! not tough scripting but some shell commands

  6. #6
    Join Date
    Nov 2006
    Location
    College Station, TX
    Posts
    185
    The sockets API in PHP is pretty much just a direct layer over the C sockets API, so that should be pretty easy to figure out if you're smart enough to be messing with it.

    For an easier route, though -- just have PHP make some exec calls to ping or fping. I'd suggest fping.

    And if you'd like to avoid this all together -- install Nagios.

  7. #7
    Quote Originally Posted by karlkatzke View Post
    And if you'd like to avoid this all together -- install Nagios.
    Actually that's not a bad idea..

    Thanks for the suggestion

    If for example a client decided to change hosting companies..would it notify of a change in the IP address?
    Optimize Your Web Hosting Operation - Empire Consultant

  8. #8
    Join Date
    Nov 2006
    Location
    College Station, TX
    Posts
    185
    You can get nagios to do anything. All you need to do is write a plugin (if one doesn't already exist) to watch it and either report "OK" or "WARNING" or "CRITICAL" to standard out. You can write these scripts in PHP, Bash, C, Perl, and pretty much anything else that can, well, output a line of text to standard out.

  9. #9
    Ohh I like that

    Thanks for the info, I appreciate it.
    Optimize Your Web Hosting Operation - Empire Consultant

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •