1 | #include <MsgBoxConstants.au3> |
---|
2 | |
---|
3 | Example() |
---|
4 | |
---|
5 | Func Example() |
---|
6 | TCPStartup() |
---|
7 | |
---|
8 | OnAutoItExitRegister("OnAutoItExit") |
---|
9 | |
---|
10 | Local $sIPAddress = "127.0.0.1" |
---|
11 | Local $iPort = 65432 |
---|
12 | |
---|
13 | Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100) |
---|
14 | Local $iError = 0 |
---|
15 | |
---|
16 | If @error Then |
---|
17 | $iError = @error |
---|
18 | MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server: Could not listen, Error code: " & $iError) |
---|
19 | Return False |
---|
20 | EndIf |
---|
21 | |
---|
22 | Local $iSocket = 0 |
---|
23 | Do |
---|
24 | $iSocket = TCPAccept($iListenSocket) |
---|
25 | |
---|
26 | If @error Then |
---|
27 | $iError = @error |
---|
28 | MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server: Could not accept the incoming connection, Error code: " & $iError) |
---|
29 | Return False |
---|
30 | EndIf |
---|
31 | Until $iSocket <> -1 |
---|
32 | |
---|
33 | ;~ TCPCloseSocket($iListenSocket) |
---|
34 | |
---|
35 | MsgBox(0, "", "Hello !") |
---|
36 | |
---|
37 | TCPCloseSocket($iSocket) |
---|
38 | EndFunc ;==>Example |
---|
39 | |
---|
40 | Func OnAutoItExit() |
---|
41 | TCPShutdown() |
---|
42 | EndFunc ;==>OnAutoItExit |
---|