added TcpConnection::fileno() to expose the internal filedescriptor / socket
This commit is contained in:
parent
c63f62189e
commit
f05aba0782
|
|
@ -117,6 +117,12 @@ public:
|
|||
*/
|
||||
virtual ~TcpConnection() noexcept {}
|
||||
|
||||
/**
|
||||
* The filedescriptor that is used for this connection
|
||||
* @return int
|
||||
*/
|
||||
int fileno() const;
|
||||
|
||||
/**
|
||||
* Process the TCP connection
|
||||
*
|
||||
|
|
|
|||
|
|
@ -142,6 +142,12 @@ public:
|
|||
// close the socket
|
||||
close(_socket);
|
||||
}
|
||||
|
||||
/**
|
||||
* The filedescriptor of this connection
|
||||
* @return int
|
||||
*/
|
||||
virtual int fileno() const override { return _socket; }
|
||||
|
||||
/**
|
||||
* Process the filedescriptor in the object
|
||||
|
|
|
|||
|
|
@ -27,6 +27,16 @@ TcpConnection::TcpConnection(TcpHandler *handler, const Address &address) :
|
|||
_state(new TcpResolver(this, address.hostname(), address.port(), handler)),
|
||||
_connection(this, address.login(), address.vhost()) {}
|
||||
|
||||
/**
|
||||
* The filedescriptor that is used for this connection
|
||||
* @return int
|
||||
*/
|
||||
int TcpConnection::fileno() const
|
||||
{
|
||||
// pass on to the state object
|
||||
return _state->fileno();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the TCP connection
|
||||
* This method should be called when the filedescriptor that is registered
|
||||
|
|
|
|||
|
|
@ -57,6 +57,12 @@ public:
|
|||
*/
|
||||
virtual ~TcpState() = default;
|
||||
|
||||
/**
|
||||
* The filedescriptor of this connection
|
||||
* @return int
|
||||
*/
|
||||
virtual int fileno() const { return -1; }
|
||||
|
||||
/**
|
||||
* Process the filedescriptor in the object
|
||||
* @param fd The filedescriptor that is active
|
||||
|
|
|
|||
Loading…
Reference in New Issue