[英]C++ network stream
I am a newbie using C++ and I have a background with Java 我是一个使用C ++的新手,我有一个Java背景
I am working on a simple linux server using c++ and I have a question about converting byte data. 我正在使用c ++在一个简单的Linux服务器上工作,我有一个关于转换字节数据的问题。
In Java, I can use putShort, or putString in ByteBuffer and simply send the buffer over socket using byteBuffer.array() 在Java中,我可以在ByteBuffer中使用putShort或putString,并使用byteBuffer.array()简单地通过套接字发送缓冲区
What is the corresponding c++ code of this? 这相应的c ++代码是什么?
Thanks in advance. 提前致谢。
The C++ standard library does not include networking facilities. C ++标准库不包括网络设施。 However the famous boost libraries do include this in the form of Boost.Asio .
然而,着名的boost库确实以Boost.Asio的形式包含了它。 The documentation includes several examples of use .
该文档包括几个使用示例 。
boost::asio::mutable_buffer
or boost::asio::basic_streambuf
seem similar to what you describe. boost::asio::mutable_buffer
或boost::asio::basic_streambuf
看起来与你描述的类似。
C++ itself does not have networking builtin. C ++本身没有内置的网络。 You might want to skim through the boost libraries .
您可能想浏览一下boost库 。 Install them, they are common, and read the documentation.
安装它们,它们很常见,并阅读文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.