0

I have a model in codeigniter which contains a function that pings servers and stores data in an external server. I am trying to use my main server to call the function on the slave server. Here is the function:

public function check_online($ip, $port){
    if(!$socket = stream_socket_client('tcp://'.$ip.':'.$port, $this->timeout)) {
        return FALSE;

            } else {

        return TRUE;
    }

}

Help would be very greatly appreciated.

user229044
  • 232,980
  • 40
  • 330
  • 338
  • 1
    Consider creating some nice RESTful services if you're passing data around, or a pub/sub if you just need to notify other boxes of stuff. – Brad Sep 07 '13 at 03:33

1 Answers1

0

What you're describing seems to be a remote invocation of a function on a different machine. Usually, this requires you to set up a function stub at your client end and set up a channel. But since you're using PHP, you can use a simple POST request to accomplish the same.

Here is an example: PHP: Remote Function Call and returning the result?

However, if the remote function only "stores" the data in (say) MySQL, then I would suggest you to re-design your application so that you don't need a separate function on a different server to do the store operation.

Community
  • 1
  • 1
Abhishek
  • 141
  • 1
  • 5
  • Thanks for the link. I use a main server to carry out the website and seperate server to do the heavy lifting (Pinging thousands of listing etc) – user2756184 Sep 07 '13 at 03:42