简体   繁体   中英

C++ network stream

I am a newbie using C++ and I have a background with Java

I am working on a simple linux server using c++ and I have a question about converting byte data.

In Java, I can use putShort, or putString in ByteBuffer and simply send the buffer over socket using byteBuffer.array()

What is the corresponding c++ code of this?

Thanks in advance.

The C++ standard library does not include networking facilities. However the famous boost libraries do include this in the form of Boost.Asio . The documentation includes several examples of use .

boost::asio::mutable_buffer or boost::asio::basic_streambuf seem similar to what you describe.

C++ itself does not have networking builtin. You might want to skim through the boost libraries . Install them, they are common, and read the documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM