Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ network stream

Tags:

c++

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.

like image 911
codereviewanskquestions Avatar asked Jul 19 '26 02:07

codereviewanskquestions


1 Answers

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.

like image 126
R. Martinho Fernandes Avatar answered Jul 21 '26 19:07

R. Martinho Fernandes