Opened 12 years ago
Closed 12 years ago
#4170 closed Bugs (fixed)
Error using null_buffers in async_send_to in Windows
Reported by: | Owned by: | chris_kohlhoff | |
---|---|---|---|
Milestone: | Boost 1.44.0 | Component: | asio |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Cc: |
Description
While exploring the boost.asio library I came across a bug caused by a typo in one of the header files. When async_send_to is invoked on an UDP socket with null_buffers, the following sequence of calls takes place:
basic_datagram_socket->async_send_to(const ConstBufferSequence& buffers, const endpoint_type& destination, WriteHandler handler)
datagram_socket_service->async_send_to(implementation_type& impl, const ConstBufferSequence& buffers, const endpoint_type& destination, socket_base::message_flags flags, WriteHandler handler)
win_iocp_socket_service->async_send_to(implementation_type& impl, const ConstBufferSequence& buffers, const endpoint_type& destination, socket_base::message_flags flags, Handler handler)
The problem is, the 3rd function is the generic version of async_send_to() which expects a valid buffer. Passing null_buffers causes an error.
There is also a specialization of async_send_to() for the null_buffers case. Unfortunately, it's never called, because in the declaration some arguments are out of place. The declaration is: async_send_to(implementation_type& impl, const null_buffers&, socket_base::message_flags, const endpoint_type&, Handler handler)
. Compared to the generic version, the flags
and destination
arguments are swapped. After correcting the order of these two arguments, async_send_to() works as expected.
Change History (2)
comment:1 by , 12 years ago
Milestone: | Boost 1.43.0 → Boost 1.44.0 |
---|
comment:2 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [62644]) Merge from trunk.
........
r62497 | chris_kohlhoff | 2010-06-07 09:28:58 +1000 (Mon, 07 Jun 2010) | 2 lines
Fix handling of small but non-zero timeouts. Fixes #4205.
........
r62499 | chris_kohlhoff | 2010-06-07 10:00:45 +1000 (Mon, 07 Jun 2010) | 2 lines
Reworked implementation MkII. Also fixes #4170.
........
r62530 | chris_kohlhoff | 2010-06-08 09:24:28 +1000 (Tue, 08 Jun 2010) | 2 lines
Fixes for MSVC 7.1, Borland.
........
r62531 | chris_kohlhoff | 2010-06-08 09:29:05 +1000 (Tue, 08 Jun 2010) | 2 lines
Some changes for Symbian support.
........
r62549 | chris_kohlhoff | 2010-06-08 14:27:26 +1000 (Tue, 08 Jun 2010) | 2 lines
Fix typo in tutorial. Fixes #4252.
........
r62556 | chris_kohlhoff | 2010-06-08 19:01:39 +1000 (Tue, 08 Jun 2010) | 2 lines
Ensure unsigned char is used with isdigit. Fixes #4201.
........
r62558 | chris_kohlhoff | 2010-06-08 21:01:57 +1000 (Tue, 08 Jun 2010) | 2 lines
Fix handling of empty buffer sequences.
........
Thanks for the report. I see that the problem also applies to non-windows platforms.
Note that async_send_to/null_buffers isn't especially useful anyway. You can just use async_send instead, as the destination is ignored in any case.