Ejemplo n.º 1
0
function get_port($arg)
{
    if ($arg == "-p" || $arg == "-n" || $arg == "-h") {
        return -1;
    }
    if (is_numeric($arg) == FALSE || $argv > 65535) {
        aff_error("port " . $arg . " is not a valid port !!!");
        return -1;
    }
    return $arg;
}
Ejemplo n.º 2
0
function enter_the_game($player)
{
    if ($player->connect() == TRUE) {
        if ($player->receive_msg() == "BIENVENUE") {
        }
        $player->send_msg($player->team_name);
        //envoi du nom de team
        $player->receive_msg();
        aff_error("Je ne recois pas le BIENVENUE");
        return;
    } else {
        aff_error("Connection FAIL");
    }
    $player->disconnect();
}
Ejemplo n.º 3
0
 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;
 }