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 8257967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:22:46+00:00 2026-06-08T02:22:46+00:00

I have a TCP socket that I want to bind to a local endpoint.

  • 0

I have a TCP socket that I want to bind to a local endpoint.

I have 2 scenarios:

  1. Connecting the socket to a local endpoint which is not in use and not waiting for a connection.
  2. Connecting the socket to a local endpoint which is used / not properly closed on a previous run.

I used to initialize the acceptor using its constructor passing it the io_service and the endpoint, but when it tries to connect to the used endpoint, the acceptor crashed.

acceptor_(io_service_, endpoint)

The next thing I did is to change the constructor to only get the io_service (which promises the socket will not be opened).

acceptor_(io_service_)

I saw that asio has a bind() function that binds the socket with a local endpoint.
The function bind() has a parameter that indicates if an error has occurred, but for both the scenarios above it returns the same error.

boost::system::error_code ec;
acceptor_.bind(endpoint, ec);

if(ec)
{
    // SOME ERROR NOTIFYING
// EDIT: error code returned is 10009
}

Is there a way to connect to the endpoint and getting different errors for this types of errors?

  • 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-08T02:22:48+00:00Added an answer on June 8, 2026 at 2:22 am

    The socket for the acceptor I used was really not valid.

    according to boost’s code (located at: boost asio implementation), I saw that the the constructor that receives both io_service and endpoint opens the socket using the protocol from the endpoint itself, and only then binds it with the acceptor.

    the solution is to initialize the acceptor only with the io_service, then open the acceptor and then binding the endpoint to it.

    thanks for comments!

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

Sidebar

Related Questions

I have a TCP socket connection where I get byte array of data which
I have a tcp socket on which I receive video stream. I want to
I have a TCP socket server and I want to do the following w/o
I have a java server that has to communicate over a TCP socket to
I have a sample TCP client and server application that I want to run
i have a TCP server which receives requests from clients. i want to make
I have a console that I want to use to invoke commands on a
I am making an application that accepts a TCP Socket connection and displays the
I want to get the IP address of the socket that's connected to my
I have a list of objects and I want to sent it thought TCP

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.