AutoIt
AutoIt
Move a Connection into a Socket Set
See more Socket/SSL/TLS Examples
Demonstrates Socket.TakeSocket, which moves a connection into a newly created member of this object's socket set. After one or more calls, the object acts as a set of sockets.
Background. A socket set groups multiple connections so they can be monitored together with the SelectForReading and SelectForWriting methods. After success, the source socket holds no connection.
Chilkat AutoIt Downloads
Local $bSuccess = False
$oListenSock = ObjCreate("Chilkat.Socket")
$bSuccess = $oListenSock.BindAndListen(5000,25)
If ($bSuccess = False) Then
ConsoleWrite($oListenSock.LastErrorText & @CRLF)
Exit
EndIf
$oConnectedSock = ObjCreate("Chilkat.Socket")
$bSuccess = $oListenSock.AcceptNext(20000,$oConnectedSock)
If ($bSuccess = False) Then
ConsoleWrite($oListenSock.LastErrorText & @CRLF)
Exit
EndIf
; Move the connection out of connectedSock and into a newly created member of this object's socket
; set. After one or more such calls, socketSet acts as a set of connected sockets (useful with the
; SelectForReading / SelectForWriting methods). After success, connectedSock holds no connection.
$oSocketSet = ObjCreate("Chilkat.Socket")
$bSuccess = $oSocketSet.TakeSocket($oConnectedSock)
If ($bSuccess = False) Then
ConsoleWrite($oSocketSet.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Connection added to the socket set." & @CRLF)