[ 求指导 ] AutoIT TCPCONNECT函数如何支持IPV6

  由于工具改造需要,AutoIt语言中如何实现TCPCONNECT函数支持IPV6。是否可以用Python/Java语言重写函数使其返回值与原支持IPV4的TCPCONNECT函数相同满足兼容性。当前TCPCONNECT函数仅支持IPV4。函数原型如下:

 TCPCONNET函数示例如下:---凑够150个字

#include <MsgBoxConstants.au3>

; I am the client, start me after the server! (Start first the TCPAccept example script).

Example()

Func Example()
    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65432 ; Port used for the connection.

    ; Assign a Local variable the socket and connect to a Listening socket with the IP Address and Port specified.
    Local $iSocket = TCPConnect($sIPAddress, $iPort)

    ; If an error occurred display the error code and return False.
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        Local $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not connect, Error code: " & $iError)
        Return False
    Else
        MsgBox($MB_SYSTEMMODAL, "", "Connection successful")
    EndIf

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>Example

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit

猜你喜欢

转载自www.cnblogs.com/linyfeng/p/10646557.html
今日推荐