论坛: 网站建设 标题: Perl的socket模块 复制本贴地址    
作者: xingguojun [xingguojun]    论坛用户   登录
#!/usr/bin/perl
use IO..Socket;
printf"IIS5.0SEARCH\nWritten by Georgi Guninski wait some time\n";
if(@ATGV<2){DIR"\nUsage:IIS5host port\n";}
$port=@ARGV[1];
$host=@ARGV[0];
sub vv()
{
$11=$_[0];#length of buffer
$ch=$_[1];
$socket=IO..Sochet..INET_>new(PeerAddr=>$hest, PeerPort=>
$port,Proto to overflow
$xml=`<?xml version="1.0"?><D:searchrequsest
  

谁能告诉我这段代码是干什么的?
我自己用过怎么没有用啊?


[此贴被 咖啡╃泡面(aoming) 在 04月25日18时50分 编辑过]

地主 发表时间: 04/20 11:14

回复: aoming [aoming]   版主   登录
是perl脚本
调用了一个模块use IO::Socket;从这个模块名称看,可能是使用一个套接字进行端口类的编程;
,后面sub定义了一个子程序vv()
面向对象的编程我不行,所以perl模块这一节非常不熟悉。细节问一下netdemom;
至于脚本中的其他部分,没有什么特别的,只是一些赋值。而且你的脚本应该有问题,没贴完整。

  
引用:
我自己用过怎么没有用啊

检查
1、你有没有安装perl
2、你的操作系统是什么?如果perl的安装路径不是/usr/bin/perl,那运行了也是白运行
3、你的lib里有没有socket这个模块


[此贴被 咖啡╃泡面(aoming) 在 04月21日14时09分 编辑过]

B1层 发表时间: 04/21 14:42

回复: aoming [aoming]   版主   登录
一起参考 http://aspn.activestate.com/ASPN/CodeDoc/IO/IO/Socket.html
=================

IO::Socket
Perl module - Part of CPAN distribution IO 1.20. 


--------------------------------------------------------------------------------

NAME 
SYNOPSIS 
DESCRIPTION 
CONSTRUCTOR 
METHODS 
SEE ALSO 
AUTHOR 
COPYRIGHT 

--------------------------------------------------------------------------------

NAME 
IO::Socket - Object interface to socket communications 

SYNOPSIS 
    use IO::Socket;
DESCRIPTION 
IO::Socket provides an object interface to creating and using sockets. It is built upon the IO::Handle interface and inherits all the methods defined by IO::Handle. 

IO::Socket only defines methods for those operations which are common to all types of socket. Operations which are specified to a socket in a particular domain have methods defined in sub classes of IO::Socket 

IO::Socket will export all functions (and constants) defined by Socket. 

CONSTRUCTOR 
new ( [ARGS] ) 
Creates an IO::Socket, which is a reference to a newly created symbol (see the Symbol package). new optionally takes arguments, these arguments are in key-value pairs. new only looks for one key Domain which tells new which domain the socket will be in. All other arguments will be passed to the configuration method of the package for that domain, See below. 

 NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
 
As of VERSION 1.18 all IO::Socket objects have autoflush turned on
by default. This was not the case with earlier releases.
 NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
METHODS 
See perlfunc for complete descriptions of each of the following supported IO::Socket methods, which are just front ends for the corresponding built-in functions: 

    socket
    socketpair
    bind
    listen
    accept
    send
    recv
    peername (getpeername)
    sockname (getsockname)
    shutdown
Some methods take slightly different arguments to those defined in perlfunc in attempt to make the interface more flexible. These are 

accept([PKG]) 
perform the system call accept on the socket and return a new object. The new object will be created in the same class as the listen socket, unless PKG is specified. This object can be used to communicate with the client that was trying to connect. In a scalar context the new socket is returned, or undef upon failure. In an array context a two-element array is returned containing the new socket and the peer address, the list will be empty upon failure. 

Additional methods that are provided are 

timeout([VAL]) 
Set or get the timeout value associated with this socket. If called without any arguments then the current setting is returned. If called with an argument the current setting is changed and the previous value returned. 
sockopt(OPT [, VAL]) 
Unified method to both set and get options in the SOL_SOCKET level. If called with one argument then getsockopt is called, otherwise setsockopt is called. 
sockdomain 
Returns the numerical number for the socket domain type. For example, for a AF_INET socket the value of &AF_INET will be returned. 
socktype 
Returns the numerical number for the socket type. For example, for a SOCK_STREAM socket the value of &SOCK_STREAM will be returned. 
protocol 
Returns the numerical number for the protocol being used on the socket, if known. If the protocol is unknown, as with an AF_UNIX socket, zero is returned. 
connected 
If the socket is in a connected state the the peer address is returned. If the socket is not in a connected state then undef will be returned. 
SEE ALSO 
Socket, IO::Handle, IO::Socket::INET, IO::Socket::UNIX 

AUTHOR 
Graham Barr <gbarr@pobox.com> 

COPYRIGHT 
Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. 




[此贴被 咖啡╃泡面(aoming) 在 04月23日19时21分 编辑过]

B2层 发表时间: 04/23 19:31

论坛: 网站建设

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号