Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8863503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:59:40+00:00 2026-06-14T15:59:40+00:00

I’m currently trying to write some code with boost::asio, compiling with clang 3.1. I

  • 0

I’m currently trying to write some code with boost::asio, compiling with clang 3.1.

I have a simple function object:

struct tcp_socket_match_condition
{
    template <typename TIter>
    std::pair<TIter, bool> operator()(TIter begin, TIter end) const
    {
        auto result(std::find(begin, end, '\n'));
        const bool found(result != end);
        return std::make_pair(found ? ++result : end, found);
    }
}; 

I attempt to pass this to the boost::asio::read_until function like so:

boost::asio::read_until(socket, stream, match_condition_, error); 

The compiler error generated looks to point out that it can’t find the correct function overload. Any ideas why this isn’t working?

I’ve provided the full class and compiler error.

In file included from src/network/admin_socket.cpp:1:
In file included from include/bytes42/arthur/network/admin_socket.hpp:4:
include/bytes42/arthur/network/tcp_socket.hpp:95:21: error: no matching function for call to 'read_until'
                    boost::asio::read_until(socket, stream, match_condition_, error);
                    ^~~~~~~~~~~~~~~~~~~~~~~
src/network/admin_socket.cpp:81:10: note: in instantiation of member function
      'bytes42::arthur::network::tcp_socket<bytes42::arthur::network::detail::tcp_socket_match_condition>::listen' requested here
        socket_.listen();
                ^
/usr/local/include/boost/asio/impl/read_until.hpp:47:13: note: candidate function [with SyncReadStream =
      boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, Allocator =
      std::__1::allocator<char>] not viable: no known conversion from 'bytes42::arthur::network::detail::tcp_socket_match_condition' to 'char' for 3rd
      argument;
std::size_t read_until(SyncReadStream& s,
            ^
/usr/local/include/boost/asio/impl/read_until.hpp:138:13: note: candidate function [with SyncReadStream =
      boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, Allocator =
      std::__1::allocator<char>] not viable: no known conversion from 'bytes42::arthur::network::detail::tcp_socket_match_condition' to
      'const std::string' (aka 'const basic_string<char, char_traits<char>, allocator<char> >') for 3rd argument;
std::size_t read_until(SyncReadStream& s,
            ^
/usr/local/include/boost/asio/impl/read_until.hpp:203:13: note: candidate function [with SyncReadStream =
      boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, Allocator =
      std::__1::allocator<char>] not viable: no known conversion from 'bytes42::arthur::network::detail::tcp_socket_match_condition' to
      'const boost::regex' (aka 'const basic_regex<char, regex_traits<char> >') for 3rd argument;
std::size_t read_until(SyncReadStream& s,
            ^
/usr/local/include/boost/asio/impl/read_until.hpp:260:13: note: candidate template ignored: substitution failure [with SyncReadStream =
      boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, Allocator =
      std::__1::allocator<char>, MatchCondition = bytes42::arthur::network::detail::tcp_socket_match_condition]
std::size_t read_until(SyncReadStream& s,
            ^
/usr/local/include/boost/asio/impl/read_until.hpp:312:20: note: candidate template ignored: substitution failure [with SyncReadStream =
      boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, Allocator =
      std::__1::allocator<char>, MatchCondition = bytes42::arthur::network::detail::tcp_socket_match_condition]
inline std::size_t read_until(SyncReadStream& s,
                   ^
/usr/local/include/boost/asio/impl/read_until.hpp:37:20: note: candidate function template not viable: requires 3 arguments, but 4 were provided
inline std::size_t read_until(SyncReadStream& s,
                   ^
/usr/local/include/boost/asio/impl/read_until.hpp:93:20: note: candidate function template not viable: requires 3 arguments, but 4 were provided
inline std::size_t read_until(SyncReadStream& s,
                   ^
/usr/local/include/boost/asio/impl/read_until.hpp:193:20: note: candidate function template not viable: requires 3 arguments, but 4 were provided
inline std::size_t read_until(SyncReadStream& s,
                   ^
1 error generated.
make: *** [build/src/network/admin_socket.o] Error 1

Class:

    template <typename TMatchCondition>
    class tcp_socket
    {
        public:
            typedef std::function<std::string(const std::string&)> data_callback;

        public:
            tcp_socket(
                const unsigned short port,
                TMatchCondition match_condition,
                data_callback callback);

            void listen();
            void stop();

        private:
            tcp_socket(const tcp_socket&)   = delete;
            tcp_socket(tcp_socket&&)        = delete;

            tcp_socket& operator=(const tcp_socket&) = delete;
            tcp_socket& operator=(tcp_socket&&)      = delete;

        private:
            const utils::entry_exit         entry_exit_;
            boost::asio::io_service         service_;
            boost::asio::ip::tcp::acceptor  acceptor_;
            TMatchCondition                 match_condition_;
            data_callback                   callback_;
    };


    template <typename TMatchCondition>
    tcp_socket<TMatchCondition>::tcp_socket(
        const unsigned short port,
        TMatchCondition match_condition,
        data_callback callback)
        : entry_exit_("tcp_socket:" + std::to_string(port))
        , acceptor_(service_, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port))
        , match_condition_(match_condition)
        , callback_(callback) {}

    template <typename TMatchCondition>
    void tcp_socket<TMatchCondition>::listen()
    {
        const auto port(acceptor_.local_endpoint().port());
        const std::string port_str(std::to_string(port));

        while(acceptor_.is_open())
        {
            boost::system::error_code error;

            utils::entry_exit ee("Listening on port " + port_str);

            boost::asio::ip::tcp::socket socket(service_);
            acceptor_.accept(socket, error);

            if(error)
            {
                if(error != boost::asio::error::bad_descriptor)
                {
                    LOG(ERROR)
                        << "An error occured while trying to accept a client connection; error="
                        << error.message();

                    sleep(1);  // don't want to flood logs
                }
            }
            else
            {
                while(socket.is_open())
                {
                    boost::asio::streambuf stream;
                    boost::asio::read_until(socket, stream, match_condition_, error);

                    const std::string msg(
                        (std::istreambuf_iterator<char>(&stream)),
                        std::istreambuf_iterator<char>());

                    LOG(INFO) << "Received message: " << msg;

                    boost::asio::write(
                        socket,
                        boost::asio::buffer(callback_(msg)),
                        error);

                    if(error)
                    {
                        if(error != boost::asio::error::broken_pipe)
                        {
                            LOG(ERROR)
                                << "Error whilst writing response, closing client connection: "
                                << error.message();
                        }

                        socket.close();

                        sleep(1);  // don't want to flood logs
                    }
                }
            }
        }
    }


    template <typename TMatchCondition>
    void tcp_socket<TMatchCondition>::stop()
    {
        boost::system::error_code error;
        acceptor_.close(error);

        if(error)
        {
            LOG(ERROR) << "Error whilst stopping TCP socket; error=" << error.message();
        }
    }                                
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:59:42+00:00Added an answer on June 14, 2026 at 3:59 pm

    I don’t think you posted the full code but the problems seems to be the match condition: Did you specify using boost::is_match_condition that your tcp_socket_match_condition is a match condition?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.