Opened 14 years ago

Closed 14 years ago

#2835 closed Bugs (wontfix)

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.

Change History (3)

comment:1 by Steven Watanabe, 14 years ago

Component: Noneasio
Owner: set to chris_kohlhoff

comment:2 by anonymous, 14 years ago

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 by chris_kohlhoff, 14 years ago

Resolution: wontfix
Status: newclosed

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.

Note: See TracTickets for help on using tickets.