Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between read_some/write_some and receive/send?

I am beginning to work with Boost Asio's TCP sockets. What is the difference between read_some and receive and what is the difference between write_some and send? Thanks!

like image 488
Brian Avatar asked Aug 12 '11 17:08

Brian


Video Answer


2 Answers

As far as I remember, read_some and receive are actually doing the same. I think receive just calls read_some or vice versa. The one naming comes from the idea of treating a socket as a file (read/write), while the other one rather comes from a connection(send /receive) point of view. Same should be true for write_some and send.

like image 52
moka Avatar answered Sep 28 '22 18:09

moka


In BOOST ASIO documentation, section TCP Clients says:

Data may be read from or written to a connected TCP socket using the receive(), async_receive(), send() or async_send() member functions. However, as these could result in short writes or reads, an application will typically use the following operations instead: read(), async_read(), write() and async_write().

like image 30
gda Avatar answered Sep 28 '22 16:09

gda