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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:16:40+00:00 2026-05-11T06:16:40+00:00

I call Bind() and then Listen() on a System.Net.Sockets.Socket. None of these calls throw

  • 0

I call Bind() and then Listen() on a System.Net.Sockets.Socket. None of these calls throw an exception.

Later, I make a call to:

Socket.Select(myreadlist,mywritelist,myerrorlist,0); 

with myreadlist and myerrorlist containing the socket in question. Select reports my socket as having had an error, by leaving the socket in errorList, instead of removing it from the list. Nowhere in the program a SocketException is thrown.

I can’t seem to figure out the correct way I should be asking the system: ‘okay, so what went wrong?’

Does anybody know?

Thanks, Lucas

edit: add 4th argument=0 for select + explained better how select() tells me an error has occured.

  • 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-11T06:16:40+00:00Added an answer on May 11, 2026 at 6:16 am

    I don’t know C# but I do know UNIX sockets. My first thought was that you hadn’t called accept() on the socket before selecting for read but (and this is proof I know less about sockets than I thought) you can select in the listen state to see which sockets can be accepted. Oh well, we live and learn, even at my advanced age 🙂

    Anyhow, referring to the MSDN docs here, found through Google with (‘c#’ socket bind listen select), it states:

    If you receive a SocketException, use SocketException.ErrorCode to obtain the specific error code. Once you have obtained this code, you can refer to the Windows Socket Version 2 API error code documentation in MSDN for a detailed description of the error.

    These error codes appear to be documented here, found with a Google search on (Windows Socket Version 2 API error code documentation in MSDN).

    I’m mentioning the Google search terms in case MSDN move their pages around. I’d output the error code from the exception caught, then look it up in the list on that second link to get the actual reason for failure. Once we know that, we may be able to help you further (or it might become blindingly obvious to the point you don’t need to ask us again :-).

    One thing that seems incongruous: the prototype for the call has a fourth argument, number of microseconds to wait if no activity. Your code in the question doesn’t have that. Now, as I said, I know little about C# so it may default to something (or maybe you’ve just left it off the question by accident).

    But I would watch for a known bug if you’re using -1 (or it defaults to -1): see here for details but it basically means -1 returns immediately rather than waiting forever. Workaround is to use -2 to give you an hour or so but you’ll still have to cater for the fact it may return even though there’s been no activity.

    If it’s not throwing an exception, but simply setting the error indication in myerrorlist, that’s a hairier problem. I can see nothing is the docs that show how to easily figure it out but I’d look at these possibilities.

    • You may be able to call the WSA functions (e.g., WSAGetLastError()) to figure it out. I’m not sure how easy this is from C#. You could try to accept() the errant socket and see if that gives you an exception detailing why it’s a problem.
    • The Socket class has a Handle member which is the operating system handle for the socket. It may be possible to extract error information by following that.
    • Have you thought about using threads for connection processing and bypassing the use of select() altogether (i.e., using only accept() but from multiple threads)?

    Another thing I found has to do with socket debugging. This page has a section at the bottom which shows how to do network tracing. .NET 2 apparently didn’t support this for select() but that may have changed in the latest version.

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

Sidebar

Related Questions

server: vxworks 6.3 calls the usual socket, bind, listen, then: for (;;) { client
How can I bind arguments to a Python function so that I can call
I use glBindTexture() to bind a previously created texture. After the glBindTexture() call I
From: http://ejohn.org/apps/learn/#2 Function.prototype.bind = function(){ var fn = this, args = Array.prototype.slice.call(arguments), object =
A call to clear on a QByteArray generates the following exception: * glibc detected
In my JS I have the following ajax call, that bind the resulting json
If I use socket.makefile and then close the file object as well as the
I have a this asp.net page which upon first time load: 1: Make a
If I bind a socket to INADDR_ANY I know that it will accept incoming
I bind my control to a dataset like this: txt.DataBindings.Add(Text, ds, true, DataSourceUpdateMode.OnPropertyChanged); Then

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.