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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:33:12+00:00 2026-05-10T19:33:12+00:00

I am using winsock and C++ to set up a server application. The problem

  • 0

I am using winsock and C++ to set up a server application. The problem I’m having is that the call to listen results in a first chance exception. I guess normally these can be ignored (?) but I’ve found others having the same issue I am where it causes the application to hang every once in a while. Any help would be greatly appreciated.

The first chance exception is:

First-chance exception at 0x*12345678* in MyApp.exe: 0x000006D9: There are no more endpoints available from the endpoint mapper.

I’ve found some evidence that this could be cause by the socket And the code that I’m working with is as follows. The exception occurs on the call to listen in the fifth line from the bottom.

  m_accept_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);    if (m_accept_fd == INVALID_SOCKET)   {     return false;   }    int optval = 1;    if (setsockopt (m_accept_fd, SOL_SOCKET, SO_REUSEADDR,                   (char*)&optval, sizeof(optval)))   {     closesocket(m_accept_fd);     m_accept_fd = INVALID_SOCKET;     return false;   }    struct sockaddr_in  local_addr;   local_addr.sin_family = AF_INET;   local_addr.sin_addr.s_addr = INADDR_ANY;   local_addr.sin_port = htons(m_port);    if (bind(m_accept_fd, (struct sockaddr *)&local_addr,            sizeof(struct sockaddr_in)) == SOCKET_ERROR)   {     closesocket(m_accept_fd);     return false;   }    if (listen (m_accept_fd, 5) == SOCKET_ERROR)   {     closesocket(m_accept_fd);     return false;   } 
  • 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-10T19:33:12+00:00Added an answer on May 10, 2026 at 7:33 pm

    On a very busy server, you may be running out of Sockets. You may have to adjust some TCPIP parameters. Adjust these two in the registry:

    HKLM\System\CurrentControlSet\Services\Tcpip\Parameters    MaxUserPort  REG_DWORD  65534 (decimal)    TcpTimedWaitDelay REG_DWORD 60 (decimal) 

    By default, there’s a few minutes delay between releasing a network port (socket) and when it can be reused. Also, depending on the OS version, there’s only a few thousand in the range that windows will use. On the server, run this at a command prompt:

    netstat -an

    and look at the results (pipe to a file is easiest: netstat -an > netstat.txt). If you see a large number of ports from 1025->5000 in Timed Wait Delay status, then this is your problem and it’s solved by adjusting up the max user port from 5000 to 65534 using the registry entry above. You can also adjust the delay by using the registry entry above to recycle the ports more quickly.

    If this is not the problem, then the problem is likely the number of pending connections that you have set in your Listen() method.

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

Sidebar

Ask A Question

Stats

  • Questions 94k
  • Answers 94k
  • 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 We produced the 'Barcodes' application for the iPhone. It can… May 11, 2026 at 6:49 pm
  • Editorial Team
    Editorial Team added an answer I had the same problem, and Chrome debugger notes the… May 11, 2026 at 6:49 pm
  • Editorial Team
    Editorial Team added an answer The exit code for hg incoming and hg outgoing is… May 11, 2026 at 6:49 pm

Related Questions

I'm working on an instant messenger client in C++ (Win32) and I'm experimenting with
it is a little bit strange to me that boost.asio doesn`t use basic concept
I`m writing a chat using WinSock2 and WinAPI functions. And I have a little
I am trying to implement a function called inet_pton which will convert a string

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.