[PHP] Soket0n xD

Iniciado por ANTRAX, Febrero 24, 2010, 11:33:18 AM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Febrero 24, 2010, 11:33:18 AM Ultima modificación: Marzo 22, 2014, 02:27:18 PM por Expermicid
script medio

Código: php

<?php

// c0ded by v3n0m - 16/02/2009 - 05:54 Am
// Name : Soket0n xD

function connection($remote, $port, $timeout = 45) {
$ip = "";
if( !preg_match('/^\d+\.\d+\.\d+$/', $remote) ){
$ip = gethostbyname($remote);
if ($ip == $remote) {
$this->errstr = "error connection socket: Unknown host";
return NULL;
}
} else $ip = $remote;

if (!($this->_SOCK = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) {
$this->errstr = "Error creatin Socket: ".socket_strerror(socket_last_error());
return NULL;
}

socket_set_nonblock($this->_SOCK);

$error = NULL;
$attempts = 0;
$timeout = 1000;
$connected;

while(!($connected = @socket_connect($this->_SOCK, $remote, $posrt+0)) && $attempts++ < $timeout) {
$error = socket_last_error();
if($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) {
$this->errstr = "Error connecting socket: ".socket_strerror($error);
socket_close($this->_SOCK);
return NULL;
}
usleep(1000);
}

if(!$connected) {
$this->errstr = "Error connecting socket: Connect timed out after $timeout seconds". socket_strerror(socket_last_error());
socket_close($this->_SOCK);
return NULL;
}

socket_set_blok($this->_SOCK);

return 1;

}
?>