In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Description
The current example uses boost asio library to send HTTP data message, and uses boost::asio::streambuf request stream to encapsulate the data message, at the end of the example.
The response packet is analyzed by string to obtain the json format packet.
# include
# include
# include
# include
Using namespace std
Using namespace boost::asio
Unsigned char ToHex (unsigned char x)
{
Return x > 9? X + 55: X + 48
}
Unsigned char FromHex (unsigned char x)
{
Unsigned char y
If (x > ='A'& & x ='a'& & x ='0' & & x > 4)
StrTemp + = ToHex ((unsigned char) str [I]% 16)
}
}
Return strTemp
}
Std::string UrlDecode (const std::string& str)
{
Std::string strTemp = ""
Size_t length = str.length ()
For (size_t I = 0; I < length; iTunes +)
{
If (str [I] ='+') strTemp + =''
Else if (str [I] = ='%')
{
Assert (I + 2 < length)
Unsigned char high = FromHex ((unsigned char) str[ + + I])
Unsigned char low = FromHex ((unsigned char) str[ + + I])
StrTemp + = high * 16 + low
}
Else strTemp + = str [I]
}
Return strTemp
}
Int HttpPost ()
{
/ / char szSrcBuffer [1024] = {"authorJson= {loginAccount:\" admin\ "} & parmJson= {code:\" SheBeiLiXianGaoJingShangChuan\ ", params: {id:\" 123456\ ", remarks:\" fire alarm\ ", time_alarm:\" 2017-1-1\ ", alarm_source:\" 192.168.1.11\ "}
Char szSrcBuffer [1024] = {"authorJson= {loginAccount:\" admin\ "} & parmJson= {code:\" SheBeiLiXianChaXun\ ", params: {}}"}
Std::string strUrlEnCodedBuffer = UrlEncode (szSrcBuffer)
Io_service iosev
Ip::tcp::socket socket (iosev)
Ip::tcp::endpoint ep (ip::address_v4::from_string ("192.168.0.88"), 8080)
Boost::system::error_code ec
Socket.connect (ep, ec)
If (ec) return-1
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.