0

If ASIO had better documentation I could probably have found for myself an answer, but instead...
Is there a way to determine bytes available to read using the asio::ip::tcp::iostream ?
I really like the tcp iostream because it's super-easy to use, but I haven't found it exactly feature-packed. Does it have a tcp socket in there somewhere?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by vijayan121
1
void foo( boost::asio::ip::tcp::iostream& stm )
{
    std::size_t bytes_available = stm.rdbuf()->available() ;
    // ...

    // the native socket descriptor can be retrieved for platform specific 
    // socket functionality not available through asio. for example:
    auto fd = stm.rdbuf()->native_handle() ; // version 1.48. 
    // IIRC, used to be stm.rdbuf()->native() earlier
    ::ifreq interface_request ;
    ::ioctl( fd, SIOCGIFNETMASK, &interface_request ) ;
    // ...
}

Edited by vijayan121: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.