• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

Perl [Perl] Funcion conectar()

Status
Not open for further replies.

Doddy

Leech
User
Joined
Apr 1, 2012
Messages
169
Reputation
0
Reaction score
406
Points
63
Credits
0
‎13 Years of Service‎
57%
Hola a todos.

Aca les dejo una funcion para conectarse mediante sockets al servidor que quieran.

Code:
>
use IO::Socket;

sub conectar {

my $sockex = new IO::Socket::INET(PeerAddr => $_[0],PeerPort => $_[1],
Proto => "tcp",Timeout  => 5);

print $sockex $_[2]."\r\n";
$sockex->read($re,5000);
$sockex->close;
return $re."\r\n";
}
Sintasis

Code:
>
conectar(host,puerto,parametro a enviar)
Ejemplo de uso

Code:
>	
$re = conectar("127.0.0.1","80","GET /sql.php HTTP/1.0\r\n");
print $re;
 
Status
Not open for further replies.
Back
Top