#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include "CoProc.au3"
#Region ### START Koda GUI section ### Form=C:\Documents and Settings\Administrator\桌面\Form2.kxf
$Form2 = GUICreate("端口探测程序", 413, 229, 298, 136)
$Label1 = GUICtrlCreateLabel("探测地址:", 24, 43, 74, 18)
GUICtrlSetFont(-1, 11, 400, 0, "宋体")
$Label2 = GUICtrlCreateLabel("探测端口:", 24, 99, 74, 18)
GUICtrlSetFont(-1, 11, 400, 0, "宋体")
$Input1 = GUICtrlCreateInput("61.135.169.105", 104, 39, 257, 22)
GUICtrlSetFont(-1, 11, 400, 0, "宋体")
$Input2 = GUICtrlCreateInput("80", 104, 95, 257, 22)
GUICtrlSetFont(-1, 11, 400, 0, "宋体")
$Start = GUICtrlCreateButton("开始", 72, 153, 97, 41)
GUICtrlSetFont(-1, 11, 400, 0, "宋体")
$Stop = GUICtrlCreateButton("停止", 232, 153, 97, 41)
GUICtrlSetFont(-1, 11, 400, 0, "宋体")
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$pid = 0
_CoProcReciver("Reciver")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
If $pid <> 0 Then ProcessClose($pid)
Exit
Case $Start
GUICtrlSetState($Start,$GUI_DISABLE)
GUICtrlSetState($Stop,$GUI_ENABLE)
$port = GUICtrlRead($Input2)
$pid = _CoProc("PortTest")
Case $Stop
GUICtrlSetState($Start,$GUI_ENABLE)
GUICtrlSetState($Stop,$GUI_DISABLE)
;MsgBox(1,"pid",$pid)
If $pid <> 0 Then ProcessClose($pid)
EndSwitch
WEnd
Func Reciver($vParameter)
If $vParameter = 1 Then
MsgBox(1,"Test","Open")
If $pid <> 0 Then ProcessClose($pid)
GUICtrlSetState($Start,$GUI_ENABLE)
GUICtrlSetState($Stop,$GUI_DISABLE)
EndIf
EndFunc
Func PortTest()
While ProcessExists($gi_CoProcParent)
TCPStartup()
$Socket = TCPConnect("61.135.169.105", 80)
TCPShutdown()
If $socket <> 1 And $socket <> 0 And $socket <> -1 Then
$result = 1
Else
$result = 0
EndIf
_CoProcSend($gi_CoProcParent, $result)
Sleep(3000)
WEnd
EndFunc