|
tcp连接时使用变量的ip地址(红色部分)连接很慢
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <Date.au3>
#include <Array.au3>
If WinExists("电脑使用记录系统服务端") Then exit
$Form1 = GUICreate("电脑使用记录系统服务端", 623, 442, 192, 124)
$ListView = GUICtrlCreateListView("", 2, 2, 800, 600)
_GUICtrlListView_AddColumn($ListView, "IP地址", 100)
_GUICtrlListView_AddColumn($ListView, "状态", 100)
_GUICtrlListView_AddColumn($ListView, "登陆时间", 100)
_GUICtrlListView_AddColumn($ListView, "用户", 100)
GUISetState(@SW_SHOW)
Global $c_ip, $s_ip="10.72.139.253", $c_port=65431, $s_port=65432, $socket = -1, $Data,$ping_flag=1,$i,$listen_socket
$c_ip=@IPAddress1
Dim $ip1=StringSplit($c_ip,".")
Dim $m=0,$s_ip=""
Local $avArray[1]
For $m =1 to 254
$s_ip = StringStripWS($ip1[1]& "."&$ip1[2]& "." &$ip1[3]& "." & $m,8)
_ArrayAdd($avArray, $s_ip)
Next
$ip_n=0
$szData = "s_IP|" & $c_ip&"|"& $c_port
TCPStartup ( )
While 1
$nMsg = GUIGetMsg()
If $ip_n<255 Then
$ip_n=$ip_n+1
$s_ip=$avArray[$ip_n]
EndIf
$listen_socket = TCPConnect($s_ip,$s_port)
If $listen_socket =-1 then TCPCloseSocket($listen_socket )
If $listen_socket <> -1 Then TCPSend($listen_socket , StringToBinary($szData, 4))
Switch $nMsg
Case $GUI_EVENT_CLOSE
TCPCloseSocket($listen_socket )
TCPShutdown ( )
Exit
endSwitch
wend |
|