1 | Local $ip = "127.0.0.1" |
---|
2 | Local $port = "65432" |
---|
3 | |
---|
4 | Local $Approve = "Test" |
---|
5 | Local $Recv = 0 |
---|
6 | Local $TCPConn |
---|
7 | |
---|
8 | OnAutoItExitRegister("OnAutoItExit") |
---|
9 | |
---|
10 | starttcp() |
---|
11 | |
---|
12 | Func 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 |
---|
28 | EndFunc ;==>starttcp |
---|
29 | |
---|
30 | |
---|
31 | Func OnAutoItExit() |
---|
32 | TCPCloseSocket($TCPConn) |
---|
33 | TCPShutdown() |
---|
34 | EndFunc;==>OnAutoItExit |
---|