- 论坛徽章:
- 0
|
- #!/usr/bin/perl -w
- use strict;
- use IO::Socket;
- my ($host, $port, $handle);
- unless (@ARGV == 2) { die "usage: $0 host port" };
- ($host, $port) = @ARGV;
- my $type=SOCK_STREAM;
- # create a tcp connection to the specified host and port
- $handle = IO::Socket::INET->new(Proto => "tcp",
- PeerAddr => $host,
- PeerPort => $port,
- Type=>$type
- )
- or die "can't connect to port $port on $host: $!";
- die "SOCKET creat error:$!" unless $handle;
- open(MYFILE,"mail.txt")or die "can't open file:$!";\
- seek (MYFILE,0,0);
- while(<MYFILE>)
- {
- print $handle $_ or die "Send message error:$!";
- }
- print $handle "\0";
- close ($handle);
复制代码 上面是我写的一个client,我尝试通过这个套接字接受返回的数据,我使用了accept去接受数据,不过没有什么反应,哪位熟悉这个的希望指点一下小弟,不胜感激。 |
|