Cleaned up Listener code

Now inherits a 'Listener' class, instead of Socket.
This commit is contained in:
Fred Nicolson
2017-03-31 12:15:13 +01:00
parent 4512bd49e7
commit e15afb3d87
6 changed files with 50 additions and 36 deletions
+5 -1
View File
@@ -77,8 +77,12 @@ namespace fr
return Socket::Success;
}
Socket::Status SSLListener::accept(SSLSocket &client)
Socket::Status SSLListener::accept(Socket &client_)
{
//Cast to SSLSocket. Will throw bad cast on failure.
SSLSocket &client = dynamic_cast<SSLSocket&>(client_);
//Initialise mbedtls
int error = 0;
std::unique_ptr<mbedtls_ssl_context> ssl(new mbedtls_ssl_context);
mbedtls_ssl_init(ssl.get());
+4 -1
View File
@@ -66,8 +66,11 @@ namespace fr
return Socket::Success;
}
Socket::Status TcpListener::accept(TcpSocket &client)
Socket::Status TcpListener::accept(Socket &client_)
{
//Cast to TcpSocket. Will throw bad cast on failure.
TcpSocket &client = dynamic_cast<TcpSocket&>(client_);
//Prepare to wait for the client
sockaddr_storage client_addr;
int client_descriptor;