jesobreira / authread Goto Github PK
View Code? Open in Web Editor NEWThreads emulation for AutoIt3
Threads emulation for AutoIt3
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.16.1
Author: myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIError.au3>
#include 'authread.au3'
Opt("GUIOnEventMode", 1)
Global $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
Global $iPort = 23456 ; Port used for the connection.
_AuThread_Startup()
;_GUI()
;_StreamData()
_Main()
Func _GUI()
$Form1 = GUICreate("Form1", 1477, 385, 216, 214)
$Connect = GUICtrlCreateButton("Connect", 1400, 8, 75, 21)
$Tab1 = GUICtrlCreateTab(8, 32, 1465, 329)
GUICtrlSetOnEvent(-1, "Tab1Change")
$TabSheet1 = GUICtrlCreateTabItem("Terminal")
$TabSheet2 = GUICtrlCreateTabItem("Storico")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
GUICtrlSetOnEvent($Connect,_Main())
EndFunc
Func _StreamData()
TCPStartup() ; Start the TCP service.
; Register OnAutoItExit to be called when the script is closed.
OnAutoItExitRegister("OnAutoItExit")
If Not MyTCP_Server($sIPAddress, $iPort) Then Exit
EndFunc
Func MyTCP_Server($sIPAddress, $iPort)
; Assign a Local variable the socket and bind to the IP Address and Port specified with a maximum of 100 pending connexions.
Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100)
Local $iError = 0
If @error Then
; Someone is probably already listening on this IP Address and Port (script already running?).
$iError = @error
MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not listen, Error code: " & $iError & @CRLF & _WinAPI_GetErrorMessage($iError))
Return False
EndIf
; Assign a Local variable to be used by the Client socket.
Local $iSocket = 0
Do ; Wait for someone to connect (Unlimited).
; Accept incomming connexions if present (Socket to close when finished; one socket per client).
$iSocket = TCPAccept($iListenSocket)
; If an error occurred display the error code and return False.
If @error Then
$iError = @error
MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not accept the incoming connection, Error code: " & $iError & @CRLF & _WinAPI_GetErrorMessage($iError))
Return False
EndIf
; If GUIGetMsg() = $GUI_EVENT_CLOSE Then Return False
Until $iSocket <> -1 ;if different from -1 a client is connected.
; Close the Listening socket to allow afterward binds.
TCPCloseSocket($iListenSocket)
; Assign a Local variable the data received.
Local $sReceived = TCPRecv($iSocket, 2048) ;we're waiting for the string "tata" OR "toto" (example script TCPRecv): 4 bytes length.
ConsoleWrite($sReceived)
; Notes: If you don't know how much length will be the data,
; use e.g: 2048 for maxlen parameter and call the function until the it returns nothing/error.
; Display the string received.
;MsgBox($MB_SYSTEMMODAL, "", "Server:" & @CRLF & "Received: " & $sReceived)
; Close the socket.
TCPCloseSocket($iSocket)
EndFunc ;==>MyTCP_Server
Func OnAutoItExit()
TCPShutdown() ; Close the TCP service.
EndFunc ;==>OnAutoItExit
Func _Main()
$hThread = _AuThread_StartThread("_StreamData")
EndFunc
While 1
Sleep(100)
WEnd
Func Tab1Change()
EndFunc
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.