xrzmjz 发表于 2010-3-12 08:01:14

端口监听程序一个,请高人帮忙调试

#NoTrayIcon
Dim $Ipaddr,$prot,$const=1,$const2=1,$const3=1,$const4=1,$const5=1,$returns,$returns2,$file,$fileopen
Local $socker
While $const=1
$Ipaddr=""
$prot=""
$const=1
$const2=1
$const3=1
$const4=1
$const5=1
$socker=""
$returns=""
$returns2=""
$file=""
While $const2=1
$Ipaddr=InputBox("端口监听器","请输入IP地址:")
If $Ipaddr="" Then
        MsgBox(0,"输入错误!","IP地址不能为空!")
Else
        If $Ipaddr="exit" Then
                Exit
        Else
                $const2=0
        EndIf
EndIf
WEnd
While $const3=1
$prot=InputBox("端口监听器","请输入端口号:")
If $prot="" Then
        MsgBox(0,"输入错误!","端口号不能为空!")
Else
        If $prot<=65535 Then
                If $prot="exit" Then
                        Exit
                Else
                        $const3=0
                EndIf
        Else
                MsgBox(0,"输入错误!","该端口号大于65535,不存在该端口!")
        EndIf
EndIf
WEnd
While $const4=1
$file=InputBox("端口监听器","请输入监听日志路径:")
If $file="" Then
        $file="D:\log.txt"
        $const4=0
Else
        If $file="exit" Then
                Exit
        Else
                $const4=0
        EndIf
EndIf
WEnd
While $const5=1
TCPStartup()
TCPConnect($Ipaddr,$prot)
$socker=TCPListen($Ipaddr,$prot,100)
$returns=TCPRecv($socker,2048,1)
If $returns<>"" Then
        BinaryToString($returns)
        $fileopen=FileOpen($file,1)
        FileWrite($fileopen,$returns)
Else
        $fileopen=FileOpen($file,1)
        FileWrite($fileopen,"程序未在该端口上监听到任何数据!"&@CRLF)
EndIf
FileClose($fileopen)
TCPCloseSocket($socker)
TCPShutdown()
HotKeySet("{ESC}","ExitS")
WEnd
$returns2=MsgBox(1,"端口扫描器","是否退出?")
If $returns2=1 Then
        Exit
EndIf
WEnd
Func ExitS()
        $const5=0
EndFunc

xrzmjz 发表于 2010-3-12 08:03:22

先简单说明一下故障
程序能够通过编译
也能够运行
但是不能监听端口的数据
请高手帮忙调试

llztt 发表于 2010-3-12 08:59:00

没在机房,不好测试
你的防火墙设置怎么样?别是被阻拦了吧

出现这故障的处理办法,越简化的网络环境越好,譬如2机交叉线互联,双机关闭防火墙,测试一下

xrzmjz 发表于 2010-3-13 04:52:42

无论用什么办法都无法监听到端口传送的数据
可以打开端口和套接字
但是无法监听数据

xrzmjz 发表于 2010-3-13 04:53:13

系统防火墙是关闭的

lxz 发表于 2010-3-13 07:23:17

我的系统防火墙是开着的

xrzmjz 发表于 2010-3-13 09:17:09

不是因为系统防火墙的缘故
我已经把系统防火墙关闭了
还是不能监听到数据
端口能够连接
套接字也能正常的打开
但是不能正常的监听到数据

nxbigdaddy 发表于 2010-7-1 17:49:37

我也有相同问题,是为什么呢?!

republican 发表于 2010-7-1 19:43:33

回复 1# xrzmjz
你要监听的是自身的IP,而非对方IP.
页: [1]
查看完整版本: 端口监听程序一个,请高人帮忙调试