banner

[Rule] Rules  [Home] Main Forum  [Portal] Portal  
[Members] Member Listing  [Statistics] Statistics  [Search] Search  [Reading Room] Reading Room 
[Register] Register  
[Login] Loginhttp  | https  ]
 
Messages posted by: vietechno  XML
Profile for vietechno Messages posted by vietechno [ number of posts not being displayed on this page: 0 ]
 
#!/usr/local/bin/perl
# file:tcp_echo_cli1.pl
# usage:tcp_echo_cli1.pl [host] [port]
# echo client,tcp version
use strict;
use Socket;
use IO::Handle;
my ($byte_out,$byte_in)=(0,0);//declare globals,create 2 global variables for keeping track of the number of bytes we send and receive.
my $host =shift || 'localhost' ;
my $port =shift ||getservbyname('echo','tcp');
my $protocol = getprotobyname('tcp') ;
$host =inet_aton($host) or die "$host :unknown host";
socket (SOCK,AF_INET,SOCK_STREAM,$protocol) or die "socket() failed:$!";
my $dest_addr=sockaddr_in($port,$host)
connect (SOCK,$dest_addr) or die "connect() failed: $!";
SOCK ->autoflush(1);
while (my $msg_out=<>smilie{
print SOCK $msg_out;
my $msg_in=<SOCK>;
print $msg_in;
$bytes_out +=length($msg_out);
$bytes_in +=length($msg_in);
}
close SOCK
print STDERR "bytes_sent=$bytes_out,bytes_received=$bytes_in\n";
Hì, tiếc là ở HN, chứ HCM thì OK rồi.
 

Powered by JForum - Extended by HVAOnline
 hvaonline.net  |  hvaforum.net  |  hvazone.net  |  hvanews.net  |  vnhacker.org
1999 - 2013 © v2012|0504|218|