heavenm 发表于 2017-5-9 16:25:08

TCP UDF的问题,2个客户端链接程序会卡住不动

本帖最后由 heavenm 于 2017-5-9 16:44 编辑

http://autoitx.com/forum.php?mod=viewthread&tid=55291&rpid=678945&ordertype=0&page=1#cs
        Download netcat at https://eternallybored.org/misc/netcat/
        Execute this script
        Run in CMD:
        nc -vv 127.0.0.1 8081
#ce

#include "TCPServer.au3"

; First we set the callback functions for the three events (none of them is mandatory)
_TCPServer_OnConnect("connected")
_TCPServer_OnDisconnect("disconnect")
_TCPServer_OnReceive("received")

; And some parameters
_TCPServer_DebugMode(True)
_TCPServer_SetMaxClients(10)

; Finally we start the server at port 8081 at any interface
_TCPServer_Start(7930)
Sleep(5000)
MsgBox(0, '','两个客户端连接,我就弹不出来了!')


Func connected($iSocket, $sIP)
;~         _TCPServer_Broadcast('new client connected guys', $iSocket)
        _TCPServer_Send($iSocket, $COOKIE_IQIYI & @CRLF)
        _TCPServer_SetParam($iSocket, "will write")
EndFunc   ;==>connected

Func disconnect($iSocket, $sIP)
        MsgBox(0, "Client disconnected", "Client " & $sIP & " disconnected from socket " & $iSocket)
EndFunc   ;==>disconnect

Func received($iSocket, $sIP, $sData, $sPar)
        MsgBox(0, "Data received from " & $sIP, $sData & @CRLF & "Parameter: " & $sPar)
        _TCPServer_Send($iSocket, "You wrote: " & $sData)
        _TCPServer_SetParam($iSocket, 'will write again')
EndFunc   ;==>received

While 1

        Sleep(100)
WEnd
用一个NC连接不会卡住,用两个的话会卡住

heavenm 发表于 2017-5-9 16:28:04

并不像作者所说,服务不会影响程序运行!只是好奇哈!
到底是哪里让他卡住了
页: [1]
查看完整版本: TCP UDF的问题,2个客户端链接程序会卡住不动