tcp连接慢 看看什么愿意求助
;服务端 说明目的向所有同网段的机器发送一个服务器ip信息#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
If WinExists("电脑使用记录系统服务端") Then exit
$Form1 = GUICreate("电脑使用记录系统服务端", 623, 442, 192, 124)
GUISetState(@SW_SHOW)
Global $c_ip, $s_ip, $c_port=65431, $s_port=65432, $socket = -1, $szData,$m,$listen_socket
$c_ip=@IPAddress1
TCPStartup ( )
$szData = "s_IP|" & $c_ip&"|"& $c_port
For $m =0 to 254
$s_ip = stringleft($c_ip, stringinstr($c_ip, '.', 0, 3)) & $m
$listen_socket = TCPConnect($s_ip,65432)
If $listen_socket=-1 then TCPCloseSocket($listen_socket)
If $listen_socket<> -1 Then TCPSend($listen_socket , StringToBinary($szData, 4))
Next
TCPCloseSocket($listen_socket )
TCPShutdown ( )
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
;客户端
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("电脑使用记录系统——客户端", 623, 442, 192, 124)
GUISetState(@SW_SHOW)
Global $c_ip = @IPAddress1, $s_ip, $c_port, $s_port, $Data, $listen_mark = 1,$listen_socket,$ConnectedSocket
TCPStartup()
$listen_socket = TCPListen($c_ip, 65432)
While 1
$ConnectedSocket = TCPAccept($listen_socket)
If $listen_mark = 1 and $ConnectedSocket >= 0Then
TCPAccept($listen_socket)
$recv = TCPRecv($ConnectedSocket, 512)
$recv = BinaryToString($recv, 4)
$Data = StringSplit($recv, "|")
If $Data = "s_IP" Then
$s_ip = String($Data)
$s_port=String($Data)
MsgBox(1,"",$Data&"|"&$Data)
$listen_mark = 0
EndIf
EndIf
TCPCloseSocket($listen_socket)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
TCPCloseSocket($listen_socket )
TCPShutdown ( )
Exit
EndSwitch
WEnd 楼主建议你用TCP UDF by Kip V3吧,原生的真很难看
RE: tcp连接慢 看看什么原因求助
回复 2# tsuiTCP UDF by Kip
这个不太会用 http://www.autoitx.com/forum.php?mod=redirect&goto=findpost&ptid=28832&pid=368974&fromuid=1009
页:
[1]