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

  • Home
  • SEARCH
  • 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 177923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:08:26+00:00 2026-05-11T14:08:26+00:00

I’m trying to create something similar as this code found at the boost.asio examples.

  • 0

I’m trying to create something similar as this code found at the boost.asio examples.

socket.h:

class some_class { private:     ...         boost::asio::io_service io_service; public:         some_class() {              /* This stuff isn't used in the example...                ...but it doesn't change anything... */              io_service.run();         } }; 

socket.cpp:

using boost::asio::ip::tcp;  bool some_class::connect(char* host, char* port)  {     printf('Resolving hostname...\n');      /* Resolve hostname. */     tcp::resolver resolver(io_service);     tcp::resolver::query query(tcp::v4(), host, port);     tcp::resolver::iterator iterator = resolver.resolve(query);      printf('Connecting to %s:%s... ', host, port);      /* Connect to resolved hosts. */     sock->connect(*iterator);      return true; } 

g++ builds this without any errors, but the code never makes it past the resolver.resolve() call.
I’ve tried both ‘127.0.0.1’ and ‘localhost’ for host and ’80’ for port. (don’t think it should matter, but apache2 is up and running)

When I ctrl+c out of my application, it obviously terminates but it does output the ‘Connecting to string’ just before it does.

I am planning on building the example myself and seeing if the same problem occurs, and will definitely post the results here. Has anyone encountered this issue or knows what could possibly cause this behavior?

edit:
The example runs just fine… I have some debugging to do I suppose.

second edit:
I don’t get it, the only thing that could be different is host/port.
Example uses char* argv[] and I’m using:

char host[] = 'localhost'; char port[] = '80'; 

third edit:
it indeed seems to be blocking at connect, forgot to fflush(stdout). then it has to be a problem with the socket. going to do some more testing.

fourth edit:
stupid me, it wasn’t blocking at all! I was just relying too much on console output..

  • 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. 2026-05-11T14:08:27+00:00Added an answer on May 11, 2026 at 2:08 pm

    It is probably blocking on the call to connect, after the printf.

    stdout is line buffered by default, and since you do not have a \n at the end of your printf string, you will not see its output. When you kill the program, the buffer is being flushed, which is why you see the message then.

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

Sidebar

Ask A Question

Stats

  • Questions 137k
  • Answers 137k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer just put a Separator between the MenuItems. May 12, 2026 at 7:22 am
  • Editorial Team
    Editorial Team added an answer I would abstract out the "filename provider" into an class… May 12, 2026 at 7:22 am
  • Editorial Team
    Editorial Team added an answer You can edit files remotely over ftp or sftp or… May 12, 2026 at 7:22 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.