[Boost-users] [boost-users][Asio]

0 views
Skip to first unread message

Germán Diago Gómez

unread,
Nov 24, 2009, 5:44:19 AM11/24/09
to boost...@lists.boost.org
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.

_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Igor R

unread,
Nov 24, 2009, 6:29:14 AM11/24/09
to boost...@lists.boost.org
> 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.

Reply all
Reply to author
Forward
0 new messages