找回密码
 加入
搜索
查看: 4432|回复: 8

[网络通信] 端口监听程序一个,请高人帮忙调试

  [复制链接]
发表于 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
 楼主| 发表于 2010-3-12 08:03:22 | 显示全部楼层
先简单说明一下故障
程序能够通过编译
也能够运行
但是不能监听端口的数据
请高手帮忙调试
发表于 2010-3-12 08:59:00 | 显示全部楼层
没在机房,不好测试
你的防火墙设置怎么样?别是被阻拦了吧

出现这故障的处理办法,越简化的网络环境越好,譬如2机交叉线互联,双机关闭防火墙,测试一下
 楼主| 发表于 2010-3-13 04:52:42 | 显示全部楼层
无论用什么办法都无法监听到端口传送的数据
可以打开端口和套接字
但是无法监听数据
 楼主| 发表于 2010-3-13 04:53:13 | 显示全部楼层
系统防火墙是关闭的
发表于 2010-3-13 07:23:17 | 显示全部楼层
我的系统防火墙是开着的
 楼主| 发表于 2010-3-13 09:17:09 | 显示全部楼层
不是因为系统防火墙的缘故
我已经把系统防火墙关闭了
还是不能监听到数据
端口能够连接
套接字也能正常的打开
但是不能正常的监听到数据
发表于 2010-7-1 17:49:37 | 显示全部楼层
我也有相同问题,是为什么呢?!
发表于 2010-7-1 19:43:33 | 显示全部楼层
回复 1# xrzmjz
你要监听的是自身的IP,而非对方IP.
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-22 23:26 , Processed in 0.084192 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表