Ticket #3671: 01_Bug_TCP_Client.au3

File 01_Bug_TCP_Client.au3, 736 bytes (added by TJF, 5 years ago)

The Client

Line 
1Local $ip = "127.0.0.1"
2Local $port = "65432"
3
4Local $Approve = "Test"
5Local $Recv = 0
6Local $TCPConn
7
8OnAutoItExitRegister("OnAutoItExit")
9
10starttcp()
11
12Func starttcp()
13        TCPStartup()
14        $TCPConn = TCPConnect($ip, $port)
15        While 1
16                $TCPSent = TCPSend($TCPConn, $Approve)
17                $TCPRecv = TCPRecv($TCPConn, 4)
18                If $TCPRecv Then
19                        MsgBox(0,"CLIENT:","Receive: " & $TCPRecv  & @CRLF & "After pressing ok, will send 'Test'...")
20                        TCPSend($TCPConn, $Approve)
21                Endif
22                If @error Then
23                        Local $ierror = @error
24                        MsgBox(0,"CLIENT:","Server not connected! ERROR: " & $ierror)
25                        Exit
26                Endif
27        WEnd
28EndFunc   ;==>starttcp
29
30
31Func OnAutoItExit()
32    TCPCloseSocket($TCPConn)
33    TCPShutdown()
34EndFunc;==>OnAutoItExit