彪彪
openkore
全部博文(50)
C编程(0)
软件工具(0)
c++入门(2)
openkore(0)
2010年(38)
2009年(12)
kevin258
wsy52081
ddmumahh
vincerma
raveh
mwx1234
chen_xue
zjwmv
zpbobo11
分类:
2010-07-13 22:27:15
#!/usr/bin/perl -wuse strict;use IO::Socket;my $server_port = 9999;my $client;my $server = IO::Socket::INET->new(LocalPort => $server_port, Type => SOCK_STREAM, Reuse => 1, Listen => 10) or die "Couldn't be a tcp server on port $server_port: $!\n"; #while ( $client = $server->accept())my $newSocket = $server->accept();while (<$newSocket>){ print $_; #$server->send("55555555555555\n");}close($server);
客户端如下:
#!/usr/bin/perl -wuse strict;use IO::Socket;my $remote_host = '127.0.0.1';my $remote_port = 9999;my $socket = IO::Socket::INET->new(PeerAddr => $remote_host, PeerPort => $remote_port, Proto => "tcp", Type => SOCK_STREAM ) or die "Couldn't connect to $remote_host, $remote_port: $!\n";print "$socket,\t I'm is client\n"; print $socket "sucess \n";print $socket "sucess \n";my $answer = <$socket>;#my $newSocket = $socket->accept();close($socket);
上一篇:STL中MAP的使用(用MAP来存任何类型的数据)
下一篇:INFORMIX 表分区及索引
登录 注册