Skip to content

Commit 584560f

Browse files
Margaret Redmangittiver
authored andcommitted
Add getter/setter to be able to monitor if the address that Crow will handle requests on is bound.
1 parent a382bd3 commit 584560f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

include/crow/app.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,16 @@ namespace crow
323323
}
324324
}
325325

326+
/// \brief Set status variable to note that the address that Crow will handle requests on is bound
327+
void address_is_bound() {
328+
is_bound_ = true;
329+
}
330+
331+
/// \brief Get whether address that Crow will handle requests on is bound
332+
bool is_bound() const {
333+
return is_bound_;
334+
}
335+
326336
/// \brief Set the connection timeout in seconds (default is 5)
327337
self_t& timeout(std::uint8_t timeout)
328338
{
@@ -803,6 +813,7 @@ namespace crow
803813
std::uint8_t timeout_{5};
804814
uint16_t port_ = 80;
805815
unsigned int concurrency_ = 2;
816+
std::atomic_bool is_bound_ = false;
806817
uint64_t max_payload_{UINT64_MAX};
807818
std::string server_name_ = std::string("Crow/") + VERSION;
808819
std::string bindaddr_ = "0.0.0.0";

include/crow/http_server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ namespace crow // NOTE: Already documented in "crow/app.h"
200200
});
201201
}
202202
handler_->port(acceptor_.port());
203+
handler_->address_is_bound();
203204
CROW_LOG_INFO << server_name_
204205
<< " server is running at " << acceptor_.url_display(handler_->ssl_used())
205206
<< " using " << concurrency_ << " threads";

0 commit comments

Comments
 (0)