@zhongdao
2019-05-16T16:18:59.000000Z
字数 1370
阅读 1355
未分类
connection from unknown [ 10.200.1.2 ] at port 39440 at Wed May 15 17:53:58 2019
connection from localhost [ 127.0.0.1 ] at port 60886 at Wed May 15 17:54:02 2019
connection from unknown [ 10.200.1.2 ] at port 39485 at Wed May 15 17:54:02 2019
connection from unknown [ 127.0.0.1 ] at port 60932 at Wed May 15 17:54:07 2019
Use of uninitialized value in subroutine entry at /usr/lib/x86_64-linux-gnu/perl/5.22/Socket.pm line 153.
Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be 16 at /usr/lib/x86_64-linux-gnu/perl/5.22/Socket.pm line 153.
root@sqingpu:~/soft#
use Socket;
socket(Server, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR,
pack("l", 1)) || die "setsockopt: $!";
bind(Server, sockaddr_in($port, INADDR_ANY)) || die "bind: $!";
listen(Server,SOMAXCONN) || die "listen: $!";
改为 IO::Socket
use IO::Socket;
my $Server = IO::Socket::INET->new( Listen => 20,
LocalPort => $port,
Timeout => 5, #60 * 60,
Reuse => 1)
or die "No socket: $!";
https://www.perlmonks.org/?node_id=751902
先看操作系统 C语言代码,然后替换
把 socet 换 IO:Socket
初始化
然后
fileno
和
$foo = &do_accept(*Server{IO});
my server->accept();
$Server->fileno()
https://perldoc.perl.org/Socket.html
https://metacpan.org/release/IO/source/lib/IO/Socket.pm
https://metacpan.org/pod/IO%3A%3ASocket
Problem extracting socket from fileno
https://www.perlmonks.org/?node_id=751902
IO::Socket vs Socket do I “use” both?
https://stackoverflow.com/questions/22150346/iosocket-vs-socket-do-i-use-both