Mercurial > code
changeset 470:bc3a211c5e33
Socket:
- Update examples,
- Fix StreamServer, StreamClient arguments.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 05 Nov 2015 09:07:34 +0100 |
parents | bcfb05fa961c |
children | 35729a52fda5 |
files | C++/examples/Socket/stream-server.cpp C++/modules/Socket/Sockets.h |
diffstat | 2 files changed, 15 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/C++/examples/Socket/stream-server.cpp Thu Nov 05 08:58:12 2015 +0100 +++ b/C++/examples/Socket/stream-server.cpp Thu Nov 05 09:07:34 2015 +0100 @@ -25,9 +25,16 @@ int main() { #if defined(WITH_SSL) - Server server{net::Ipv4{"*", WITH_PORT}, net::Tls{net::Tls::Tlsv1, false, "test.key", "test.crt"}}; + net::Tls protocol; + + protocol.setVerify(false); + protocol.setPrivateKey("test.key"); + protocol.setCertificate("test.crt"); + protocol.setMethod(net::ssl::Tlsv1); + + Server server{std::move(protocol), net::Ipv4{"*", WITH_PORT}}; #else - Server server{net::Ipv4{"*", WITH_PORT}}; + Server server{net::Tcp{}, net::Ipv4{"*", WITH_PORT}}; #endif server.setConnectionHandler([] (const std::shared_ptr<Connection> &client) {
--- a/C++/modules/Socket/Sockets.h Thu Nov 05 08:58:12 2015 +0100 +++ b/C++/modules/Socket/Sockets.h Thu Nov 05 09:07:34 2015 +0100 @@ -3443,13 +3443,13 @@ /** * Create a stream server with the specified address to bind. * + * @param protocol the protocol (Tcp or Tls) * @param address the address to bind - * @param protocol the protocol * @param max the max number to listen * @throw Error on errors */ - StreamServer(const Address &address, Protocol protocol = {}, int max = 128) - : m_master{protocol, std::move(address)} + StreamServer(Protocol protocol, const Address &address, int max = 128) + : m_master{std::move(protocol), address} { // TODO: m_onError m_master.set(SOL_SOCKET, SO_REUSEADDR, 1); @@ -3734,12 +3734,12 @@ /** * Create a client. The client is automatically marked as non-blocking. * + * @param protocol the protocol (Tcp or Tls) * @param address the optional address - * @param type the type (Tcp or Tls) * @throw net::Error on failures */ - StreamClient(const Address &address = {}, Protocol type = {}) - : m_socket{address, std::move(type)} + StreamClient(Protocol protocol = {}, const Address &address = {}) + : m_socket{std::move(protocol), address} { m_socket.setBlockMode(false); m_listener.set(m_socket.handle(), Condition::Readable);