Rust
Rust
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 Rust Downloads
let listen_sock = chilkat::Socket::new();
if listen_sock.bind_and_listen(5000, 25).is_err() {
println!("{}", listen_sock.last_error_text());
return;
}
let connected_sock = chilkat::Socket::new();
if listen_sock.accept_next(20000, &connected_sock).is_err() {
println!("{}", listen_sock.last_error_text());
return;
}
// 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.
let socket_set = chilkat::Socket::new();
if socket_set.take_socket(&connected_sock).is_err() {
println!("{}", socket_set.last_error_text());
return;
}
println!("Connection added to the socket set.");