Modify

Ticket #2835 (closed Bugs: wontfix)

Opened 5 years ago

Last modified 5 years ago

basic_stream_socket::available() does not work reliably

Reported by: sidharth@… Owned by: chris_kohlhoff
Milestone: Boost 1.39.0 Component: asio
Version: Boost 1.38.0 Severity: Problem
Keywords: Cc:

Description

basic_stream_socket::available() often reports 0 bytes even when there is data available to be read.

The implementation of basic_stream_socket::available() for windows uses ioctlsocket() with FIONREAD which Microsoft advises against using. (recv(MSG_PEEK) is not prescribed either).

 http://support.microsoft.com/kb/192599

For clients wanting to poll for available data and then calling a blocking read, barring any other reliable way to peek for data availability, it would be better to have an isavailable() (based on select()) which a client could call before doing a read_some.

I realize the root cause is a Microsoft issue, but it's a boost asio bug at the end of the day.

Attachments

Change History

comment:1 Changed 5 years ago by steven_watanabe

  • Owner set to chris_kohlhoff
  • Component changed from None to asio

comment:2 Changed 5 years ago by anonymous

I forgot to mention that:

  • this works fine on Linux (I have run my test hundreds of times without failures)
  • I encountered this issue with boost 1.37 (a quick review showed that 1.38's implementation of available() uses ioctlsocket() as well.)

Thanks

comment:3 Changed 5 years ago by chris_kohlhoff

  • Status changed from new to closed
  • Resolution set to wontfix

How do you know that there is data waiting to be read? If you can construct a test case feel free to reopen this bug.

With respect to your "isavailable()" proposal, you already have this facility available using asynchronous reads (with or without using null_buffers) or by setting your socket to non-blocking.

N.B The Microsoft KB article is not related to the behaviour you describe. In fact, the article seems to describe ioctl/FIONREAD working as intended.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.