title: How to convert received bytes in Boost C++ to a unsigned int and to a vector of unsigned int
body: <p>I'm sending via Python TCP Socket an unsigned integer to a client written in Boost C++.
  I would like to know how to convert the received bytes in the Boost C++ socket into an unsigned integer.</p>
  
  <p><strong>Python Socket Server</strong></p>
  
  <pre><code>import socket
  import struct
  
  with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
      s.bind((HOST, PORT))
      s.listen()
      print("listening..")
      conn, addr = s.accept()
      with conn:
          print('Connected by', addr)
  
          # SENDING 10 AS AN UNSIGNED INTEGER
          conn.send(struct.pack("I",10))
  </code></pre>
  
  <p><strong>C++ Boost Client Socket</strong></p>
  
  <pre><code>#include &lt;boost/asio/local/stream_protocol.hpp&gt;
  #include &lt;boost/asio/io_service.hpp&gt;
  #include &lt;boost/asio/buffer.hpp&gt;
  #include &lt;boost/asio.hpp&gt;
  #include &lt;boost/system/error_code.hpp&gt;
  
  using namespace std;
  
  // CREATE SOCKET
  boost::asio::io_service io_context;
  boost::asio::streambuf sb;
  boost::system::error_code ec;
  boost::asio::ip::tcp::endpoint ep(boost::asio::ip::address::from_string("127.0.0.1"), 10000);
  boost::asio::ip::tcp::socket socket(io_context);
  socket.connect(ep);
  
  // READ 4 BYTES
  boost::asio::read(objSocket, sb,boost::asio::transfer_exactly(4), ec))
  
  cout &lt;&lt; "\nreceived: '" &lt;&lt; &amp;sb &lt;&lt; "'\n";
  
  // CONVERT 4 BYTES TO UNSIGNED INT
  boost::asio::streambuf::const_buffers_type bufs = sb.data();
  
  string str(boost::asio::buffers_begin(bufs), boost::asio::buffers_begin(bufs) + sb.size());
  
  sb.consume(sb.size());
  
  std::stringstream sstr(str);
  
  unsigned int receivedInt = 0;
  
  sstr &gt;&gt; receivedInt;
  
  cout &lt;&lt; "\nReceivedInt: "&lt;&lt; length;
  </code></pre>
  
  <p>PS: The C++ client receives the data (4bytes) but I can't convert it to uint. </p>
  
  <p>And how to convert bytes to a vector of unsigned int?</p>
  
  <p>Thank you in advance!</p>