| @@ -74,7 +74,8 @@ public: | |||||
| This is useful if you need to know to which port the OS has actually bound your | This is useful if you need to know to which port the OS has actually bound your | ||||
| socket when calling the constructor or bindToPort with zero as the | socket when calling the constructor or bindToPort with zero as the | ||||
| localPortNumber argument. Returns -1 if the function fails. */ | |||||
| localPortNumber argument. Returns -1 if the function fails. | |||||
| */ | |||||
| int getBoundPort() const noexcept; | int getBoundPort() const noexcept; | ||||
| /** Tries to connect the socket to hostname:port. | /** Tries to connect the socket to hostname:port. | ||||
| @@ -58,6 +58,11 @@ void InterprocessConnectionServer::stop() | |||||
| socket = nullptr; | socket = nullptr; | ||||
| } | } | ||||
| int InterprocessConnectionServer::getBoundPort() const noexcept | |||||
| { | |||||
| return (socket == nullptr) ? -1 : socket->getBoundPort(); | |||||
| } | |||||
| void InterprocessConnectionServer::run() | void InterprocessConnectionServer::run() | ||||
| { | { | ||||
| while ((! threadShouldExit()) && socket != nullptr) | while ((! threadShouldExit()) && socket != nullptr) | ||||
| @@ -71,6 +71,15 @@ public: | |||||
| */ | */ | ||||
| void stop(); | void stop(); | ||||
| /** Returns the local port number to which this server is currently bound. | |||||
| This is useful if you need to know to which port the OS has actually bound your | |||||
| socket when calling beginWaitingForSocket with a port number of zero. | |||||
| Returns -1 if the function fails. | |||||
| */ | |||||
| int getBoundPort() const noexcept; | |||||
| protected: | protected: | ||||
| /** Creates a suitable connection object for a client process that wants to | /** Creates a suitable connection object for a client process that wants to | ||||
| connect to this one. | connect to this one. | ||||
| @@ -83,7 +92,6 @@ protected: | |||||
| */ | */ | ||||
| virtual InterprocessConnection* createConnectionObject() = 0; | virtual InterprocessConnection* createConnectionObject() = 0; | ||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| ScopedPointer<StreamingSocket> socket; | ScopedPointer<StreamingSocket> socket; | ||||