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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:21:36+00:00 2026-05-31T14:21:36+00:00

I am writing a TCP server application using Winsock. The client that connects to

  • 0

I am writing a TCP server application using Winsock. The client that connects to me (for which I have no source and therefore cannot make changes) behaves as follows: If it connects and I close the connection (because it is an undesired client), it will immediately reconnect. As a result of this, I will spin like mad over my accept() calls if there’s a client out there that wants to connect to me but whom I don’t want to talk to (i.e. what I’ve called an undesired client).

I would like to find a way to prevent that mad spinning over my accept() calls. If there were only 1 desired client, I could bind my listening socket to that client’s IP address rather than INADDR_ANY. But alas, there is more than 1 desired client. As far as I know, there’s no way to allow connections from only a set of desired IP addresses when the size of that set is greater than 1.

I’ve looked at WSAAccept. Unfortunately, it looks like this would merely shift the mad spinning to a callback.

Is there a way to reject an attempted connection that doesn’t involve accept() waking up and returning (and therefore leading to all this mad spinning)?

  • 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-05-31T14:21:37+00:00Added an answer on May 31, 2026 at 2:21 pm

    I believe your question has been already asked on stackoverflow in the past. Maybe looking at these two threads will help you with your problem :

    • C++ Winsock API how to get connecting client IP before accepting the connection?

    • Winsock, accept request only from specific IP address

    If you’re afraid to experience Dos attacks or about performance issues, accept is acting on the level 4 of the OSI stack, a relatively low level which is handling the SYN-ACK negociation with the client, so a basic connection from the outside immediatly dropped after an accept() will not cause important performance issues.

    If, however, you want absolutely to accept two IP adresses I think you may have to use either a firewall or RAW sockets to retrieve directly the IP address from the TCP packet and accept the connection yourself, but this will be, I think, a huge loss of time.

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

Sidebar

Related Questions

I am writing a client-server application using TCP Sockets. The server is written in
I'm writing a client/server application in Java and I'm using TCP to transfer data
I'm writing a small (C#) client application that sends data using a TCP/IP connection
I am writing a C# console application that connects to a server trough TCP,
I am writing an application that communicates using sockets. I have a server running
I'm writing a tcp client in Delphi for a server that has a series
I have win32 application in which winsock is used for TCP/IP communication. I am
Let's say I've programmed an application which connects to a server using the Socket
I have a client/server connection over a TCP socket, with the server writing to
I'm writing a small client/server application in c++ with winsock and I can't explain

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.