title: Boost socket read functions not working
body: <p>I am trying to write a C++ code (VS2008) that will open a socket via Boost and run a user-specified command through it. So far I have this:</p>
  
  <pre><code>#include &lt;boost/asio.hpp&gt;
  #include &lt;boost/array.hpp&gt;
  #include &lt;boost/bind.hpp&gt;
  #include &lt;string&gt;
  #define MAXSIZE 1000000
  //...
  void MyClass::processCommand(std::string command)
  {
    boost::asio::io_service io;
    boost::asio::ip::tcp::socket socket(io);
    boost::asio::ip::tcp::endpoint e(boost::asio::ip::address::from_string("127.0.0.1"), 60151);  //Info for the connection I need to make...
    this-&gt;socket.open(boost::asio::ip::tcp::v4());
    this-&gt;socket.connect(e);
    this-&gt;socket.write_some(boost::asio::buffer(command, command.size());
    this-&gt;socket.send(boost::asio::buffer(command, command.size());
  
    boost::array&lt;char, MAXSIZE&gt; buffer;
    this-&gt;socket.async_read_some(boost::asio::buffer(b, MAXSIZE),
                               boost::bind(MyClass::handle_read, this,
                               boost::asio::placeholders::error,
                               boost::asio::placeholders::bytes_transferred));
  }
  
  void MyClass::handle_read(const boost::system::error_code&amp; error, size_t bytes_transferred)
  {
      //Haven't worked this part out yet...
  }
  </code></pre>
  
  <p>I tried to model my code after the example on Boost's website <a href="http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/example/cpp03/echo/async_tcp_echo_server.cpp" rel="nofollow noreferrer">here</a>. However when I try to compile this I get a ton of error messages, mostly about bind expecting a different number of arguments. I'm really new to using Boost and honestly a little lost how to do this, so I'm not sure what to do to rectify this, since it seems to match the example on their site. I also tried to do this code with Boost's read_some() function, the code for which can be found in a question I posted about that method <a href="https://stackoverflow.com/questions/25190715/boost-read-also-function-not-working-with-boostarray-cannot-use-stdarray">here</a>.</p>
  
  <p>Basically, I'm just asking what I could do to get this code to function as intended. I'm not too concerned which of the two functions I need to end up using (read_some() or async_read_some()) just as long as it works. If the other way is better, I'd greatly appreciate any help with figuring out the issue on that question. If this way is better and anyone knows how to fix it, that would be great too. Thanks a lot in advance.</p>
  
  <p><strong>EDIT</strong>: I accidentally forgot before to include the error messages I was getting. There were a lot of them (~70), all relating to <code>boost::bind</code>, and followed this syntax:</p>
  
  <pre><code>error: C2780: 'boost::_bi::bind_t&lt;Rt2,boost::_mfi::cmf8&lt;R,T,B1,B2,B3,B4,B5,B6,B7,B8&gt;,_bi::list_av_9&lt;A1,A2,A3,A4,A5,A6,A7,A8,A9&gt;::type&gt; boost::bind(boost::type&lt;T&gt;,R (__cdecl T::* )(B1,B2,B3,B4,B5,B6,B7,B8) const,A1,A2,A3,A4,A5,A6,A7,A8,A9)' : expects 11 arguments - 4 provided
  error: C2780: 'boost::_bi::bind_t&lt;Rt2,boost::_mfi::cmf7&lt;R,T,B1,B2,B3,B4,B5,B6,B7&gt;,_bi::list_av_8&lt;A1,A2,A3,A4,A5,A6,A7,A8&gt;::type&gt; boost::bind(boost::type&lt;T&gt;,R (__cdecl T::* )(B1,B2,B3,B4,B5,B6,B7) const,A1,A2,A3,A4,A5,A6,A7,A8)' : expects 10 arguments - 4 provided
  //etc.
  </code></pre>
  
  <p>It has a few of these with identical messages but saying it expected different numbers of arguments, from 11 down to 3. It also seemed to give the same general set of error messages 3 times for different formats. I'll give one example of each, since again all the others in that set of error messages are the same syntax, just for different numbers of arguments:</p>
  
  <pre><code>//first is same as above
  error: C2780: 'boost::_bi::bind_t&lt;Rt2,boost::_mfi::cmf8&lt;R,T,B1,B2,B3,B4,B5,B6,B7,B8&gt;,_bi::list_av_9&lt;A1,A2,A3,A4,A5,A6,A7,A8,A9&gt;::type&gt; boost::bind(boost::type&lt;T&gt;,R (__cdecl T::* )(B1,B2,B3,B4,B5,B6,B7,B8) const,A1,A2,A3,A4,A5,A6,A7,A8,A9)' : expects 11 arguments - 4 provided
  
  
  error: C2780: 'boost::_bi::bind_t&lt;R,boost::_mfi::cmf8&lt;R,T,A1,A2,A3,A4,A5,A6,A7,A8&gt;,_bi::list_av_9&lt;A1,A2,A3,A4,A5,A6,A7,A8,A9&gt;::type&gt; boost::bind(R (__cdecl T::* )(B1,B2,B3,B4,B5,B6,B7,B8) const,A1,A2,A3,A4,A5,A6,A7,A8,A9)' : expects 10 arguments - 4 provided
  
  
  error: C2780: 'boost::_bi::bind_t&lt;R,R(__cdecl *)(B1,B2,B3,B4,B5,B6,B7,B8,B9),_bi::list_av_9&lt;A1,A2,A3,A4,A5,A6,A7,A8,A9&gt;::type&gt; boost::bind(R (__cdecl *)(B1,B2,B3,B4,B5,B6,B7,B8,B9),A1,A2,A3,A4,A5,A6,A7,A8,A9)' : expects 10 arguments - 4 provided
  
  
  error: C2780: 'boost::_bi::bind_t&lt;boost::_bi::unspecified,F,_bi::list_av_9&lt;A1,A2,A3,A4,A5,A6,A7,A8,A9&gt;::type&gt; boost::bind(F,A1,A2,A3,A4,A5,A6,A7,A8,A9)' : expects 10 arguments - 4 provided
  
  
  error: C2780: 'boost::_bi::bind_t&lt;R,F,_bi::list_av_9&lt;A1,A2,A3,A4,A5,A6,A7,A8,A9&gt;::type&gt; boost::bind(boost::type&lt;T&gt;,F,A1,A2,A3,A4,A5,A6,A7,A8,A9)' : expects 11 arguments - 4 provided
  
  error: C2780: 'boost::_bi::bind_t&lt;R,F,_bi::list_av_9&lt;A1,A2,A3,A4,A5,A6,A7,A8,A9&gt;::type&gt; boost::bind(F,A1,A2,A3,A4,A5,A6,A7,A8,A9)' : expects 10 arguments - 4 provided
  </code></pre>
  
  <p>I also took screenshots of the full error log (or at least as much of it as I could get to fit on the screen at once) which can be seen below:
  <img src="https://i.stack.imgur.com/EPRx3.jpg" alt="Error Log">
  <img src="https://i.stack.imgur.com/NiknC.jpg" alt="Cont&#39;d"></p>