public function connect()
 {
     $temp = $this->host;
     if (($this->host = gethostbyname($this->host)) == $temp) {
         return aff_error("Unknown host !!!");
     }
     if (($this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) == FALSE) {
         return aff_error(socket_strerror(socket_last_error()));
     }
     if (socket_set_option($this->sock, SOL_SOCKET, SO_REUSEADDR, 1) == FALSE) {
         return aff_error("set option to socket failed !!!");
     }
     if (socket_connect($this->sock, $this->host, $this->port) == FALSE) {
         return aff_error(socket_strerror(socket_last_error()));
     }
     aff_ok("Connecting client " . $this->id . " on server " . $this->host . ":" . $this->port . " succeed.");
     return TRUE;
 }
Beispiel #2
0
 public function init($i, $t, $p, $h = "localhost")
 {
     /*
      A Mettre dans le construct.
     */
     $this->id = $i;
     $this->team_name = $t;
     $this->set_port($p);
     $this->set_host($h);
     /* est ce au bon endroit ?*/
     aff_ok("Initializing Zappy Client " . $this->id);
     /*
     aff_ok("Configuration : team name: ".$this->team_name."\n\t\tport: "
     	   .$this->port."\n\t\thost: ".$this->host);
     */
     return TRUE;
     /* useless... car dans la class comm
         if (init_comm_server($this->sock) == FALSE)
        return (FALSE);
        */
 }