In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
As soon as read_some encounters data to be sent, it will return immediately, but how do you know if the data has been sent?
In the current case, continue to wait for reception until the end symbol of negotiation is encountered. If the data returned by read_some is 0, the client has been shut down.
Void ReadSomeFunc ()
{
Boost::system::error_code ec
Do
{
Char szRecvBuf [10240] = {0}
Int nReadLen = m_socket.read_some (boost::asio::buffer (szRecvBuf), ec)
If (0 = = nReadLen)
{
Char szRecvBufLeft [10240] = {0}
NReadLen = m_socket.read_some (boost::asio::buffer (szRecvBufLeft), ec)
If (0 = = nReadLen) return
M_strMatch = m_strMatch + szRecvBufLeft
}
If (ec) return
M_strMatch = szRecvBuf
Int nIndexOfContentLength = m_strMatch.find ("Content-Length:", 0)
Int indexOfEnd = m_strMatch.find ("\ r\ n\ r\ n", 0)
If (nIndexOfContentLength =-1) break
If (- 1 = = indexOfEnd) break
Std::string strContextLen = m_strMatch.substr (nIndexOfContentLength + 15, indexOfEnd-nIndexOfContentLength-15)
Unsigned int nContextLen = atoi (strContextLen.c_str ())
If (nContextLen > m_strMatch.length ())
{
Char szRecvBufLeft [40960] = {0}
M_socket.read_some (boost::asio::buffer (szRecvBufLeft), ec)
M_strMatch = m_strMatch + szRecvBufLeft
}
Boost::asio::streambuf request
Std::ostream request_stream & request)
Request_stream
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.