aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/crow/websocket.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/include/crow/websocket.h b/include/crow/websocket.h
index ee0885f..c2dc3f8 100644
--- a/include/crow/websocket.h
+++ b/include/crow/websocket.h
@@ -152,7 +152,7 @@ namespace crow
else
{
buf[1] += 127;
- *(uint64_t*)(buf+2) = ((1==htonl(1)) ? (uint64_t)size : ((uint64_t)htonl((size) & 0xFFFFFFFF) << 32) | htonl((size) >> 32));
+ *reinterpret_cast<uint64_t*>(buf+2) = ((1==htonl(1)) ? static_cast<uint64_t>(size) : (static_cast<uint64_t>(htonl((size) & 0xFFFFFFFF)) << 32) | htonl(static_cast<uint64_t>(size) >> 32));
return {buf, buf+10};
}
}
@@ -191,7 +191,7 @@ namespace crow
{
is_reading = false;
- mini_header_ = htons(mini_header_);
+ mini_header_ = ntohs(mini_header_);
#ifdef CROW_ENABLE_DEBUG
if (!ec && bytes_transferred != 2)
@@ -231,9 +231,9 @@ namespace crow
case WebSocketReadState::Len16:
{
remaining_length_ = 0;
- uint16_t remaining_length16_ = 0;
+ remaining_length16_ = 0;
boost::asio::async_read(adaptor_.socket(), boost::asio::buffer(&remaining_length16_, 2),
- [this,&remaining_length16_](const boost::system::error_code& ec, std::size_t
+ [this](const boost::system::error_code& ec, std::size_t
#ifdef CROW_ENABLE_DEBUG
bytes_transferred
#endif
@@ -502,6 +502,7 @@ namespace crow
std::string message_;
std::string fragment_;
WebSocketReadState state_{WebSocketReadState::MiniHeader};
+ uint16_t remaining_length16_{0};
uint64_t remaining_length_{0};
bool close_connection_{false};
bool is_reading{false};