codereviewanskquestions
codereviewanskquestions

Reputation: 13978

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.

Upvotes: 3

Views: 5418

Answers (2)

R. Martinho Fernandes
R. Martinho Fernandes

Reputation: 234354

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.

Upvotes: 4

Sebastian Mach
Sebastian Mach

Reputation: 39089

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.

Upvotes: 2

Related Questions