What send / recv socket operations can be performed simultaneously using Boost.Asio

I know that you can run async_send and async_receive operations on TCP and UDP sockets at the same time. But what is the expected behavior in these situations:

  • call two async_send operations at the same time in the UDP socket.
  • calling two async_receive operations on a UDP socket simultaneously.
  • calling two async_send operations at the same time on a TCP socket.
  • calling two async_receive operations simultaneously on a TCP socket.

I am interested in the first case; since UDP does not necessarily preserve the order of sent packets, I don’t care if they are sent in a different order than what was called async_send.

+2
source share
1 answer

The same thing happens as without Boost ASIO:

call two async_send operations at the same time in the UDP socket.

Both datagrams will be sent.

calling two async_receive operations on a UDP socket simultaneously.

Arbitrarily, what operation will receive the next datagram, but both operations will behave normally.

calling two async_send operations at the same time on a TCP socket.

Data may alternate unpredictably.

calling two async_receive operations simultaneously on a TCP socket.

Data may alternate unpredictably.

+3
source

Source: https://habr.com/ru/post/1258248/


All Articles