Network 模块
类: TcpSocket、TcpListener、UdpSocket、Socket、SocketSelector、Packet、IpAddress、Http、Ftp(弃用)、Sftp(3.1)
命名空间: sf::Dns(3.1)
IpAddress / Dns
Section titled “IpAddress / Dns”// 弃用:sf::IpAddress::resolve(...)auto addresses = sf::Dns::resolve("www.sfml-dev.org"); // optional<vector<IpAddress>>,IPv4+IPv6sf::Dns::queryNs / queryMx / querySrv / queryTxtsf::Dns::getPublicAddress(sf::seconds(5)); // 可选 IPv6IpAddress:toString()、isV4() / isV6() 等;解析失败用 optional 表达。
Packet / Sockets
Section titled “Packet / Sockets”Packet:<</>>序列化;append/clearTcpSocket:connect、disconnect、send/receive(数据或 Packet);TLS:setupTlsClient/setupTlsServer(3.1 相关能力)UdpSocket:bind/unbind、send/receiveSocket::Status/Typescoped;getNativeHandle()(原getHandle)SocketSelector:传统add+isReady;3.1add(..., ReadinessType, callback)+dispatchReadyCallbacks()
Http(3.1 HTTPS)
Section titled “Http(3.1 HTTPS)”sf::Http http;if (!http.setHost("https://www.sfml-dev.org")) { /* 解析失败 */ }sf::Http::Request req("/");sf::Http::Response res = http.sendRequest(req); // sendRequest 现为 const// 可选关闭证书校验:sendRequest(req, sf::Time::Zero, /*verifyServer=*/false)Http::Request::Method、Response::Status 为 scoped enums。
Ftp → Sftp
Section titled “Ftp → Sftp”sf::Ftp弃用(明文)sf::Sftp:connect、login(密码或公私钥)、getDirectoryListing、download/upload(回调)、createDirectory、deleteFile、rename、disconnect