PHP
Chilkat2 PHP
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 PHP Downloads
<?php
use Chilkat2\Socket;
$listenSock = new Socket();
try {
$listenSock->BindAndListen(5000, 25);
$connectedSock = new Socket();
$listenSock->AcceptNext(20000, $connectedSock);
// 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.
$socketSet = new Socket();
$socketSet->TakeSocket($connectedSock);
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
echo "Connection added to the socket set.\n";