Global $ServerPORT=8880
Global $ClientPort=8888
TCPStartup()
$MainSocket = TCPListen(@IPAddress1, $ClientPort,100)
If $MainSocket = -1 Then Exit
While 1
Local $msg = TrayGetMsg()
NetPortMonitor() ;监听端口的函数放这里对吗?
Select
Case $msg = 0
ContinueLoop
Case $msg = $exititem
ExitLoop
EndSelect
WEnd
TCPShutdown()
ProcessClose(@AutoItPID)
Func NetPortMonitor();TCP端口监听命令接收
$ConnectedSocket = TCPAccept($MainSocket)
If $ConnectedSocket >= 0 Then ;与客户端连接成功
$rev = TCPRecv($ConnectedSocket,2048)
If StringLen($rev) > 0 Then
ClientRevCommand($rev)
TCPCloseSocket($ConnectedSocket)
$ConnectedSocket = -1
EndIf
EndIf
TCPCloseSocket($ConnectedSocket)
EndFunc
我放在上面循环结构的位置,结果造成很卡,其他功能没有办法流畅运行了.怎么处理更好呢?
在线等...... |