Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost-users][Asio]
From: Igor R (boost.lists_at_[hidden])
Date: 2009-11-24 06:29:14


> Hello. I'm implementing a server and a client in boost.asio, and I would
> like to know the differences between:
>
>
> - socket::send() and socket::write_some
>
> - socket::receive() and socket::read_some
>
>
> In the documentation, for what I read, they look like they do the same
> thing.
> Can anyone explain me the difference? Thanks.

There are different overloads of both. The overloads that take a
single parameter of ConstBufferSequence do exactly the same thing:

  template <typename ConstBufferSequence>
  std::size_t send(const ConstBufferSequence& buffers)
  {
    boost::system::error_code ec;
    std::size_t s = this->service.send(this->implementation, buffers, 0, ec);
    boost::asio::detail::throw_error(ec);
    return s;
  }

  template <typename ConstBufferSequence>
  std::size_t write_some(const ConstBufferSequence& buffers)
  {
    boost::system::error_code ec;
    std::size_t s = this->service.send(this->implementation, buffers, 0, ec);
    boost::asio::detail::throw_error(ec);
    return s;
  }

"write_some" is a part of SyncWriteStream concept. I don't know why
"send" is needed, maybe it's just for backward compatibility.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net