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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:01:09+00:00 2026-05-20T15:01:09+00:00

I’m working on some C# server project, and it’s going quite good. Today I

  • 0

I’m working on some C# server project, and it’s going quite good.

Today I changed from Async reading, to normal reading, using polling. Now when I was reading async this wasn’t a problem, but now it is.

When the client disconnects, the socket throws a SocketException, and that exception causes some pretty long delay. If I don’t stop it from throwing that exception, the entire server will freeze for about half a second. And that might not seem worth the trouble, but the server will get a pretty high amount of connects and disconnects, so it really takes too long.

Now I’m already checking the Socket.Connected property, that returns true, but after the read method it returns false.

So does anyone know how to ‘update’ the status of the connection, before trying to read it?

PS: I am catching the exception, it’s just that the delay is too big.

  • 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-20T15:01:10+00:00Added an answer on May 20, 2026 at 3:01 pm

    In typical TCP development, having a connection closed unexpectedly should be an exceptional case. You should consider implementing a more graceful system, where the one side first sends a message indicating that it’s going to disconnect, that way both sides can then close the connection without any failures.

    Bear in mind that activity is required to determine if a connection is closed or not. Per the MSDN docs on Socket.Connected, that property only reflects whether or not the connection was connected at the time the last operation was attempted.

    If you’re doing anything non-trivial with this, you should be isolating your connections with threads (not necessarily one thread per connection, as anything with high traffic would quickly overwhelm the system), but it should not be possible for a single connection to monopolize the entire server, whether that’s from a lengthy operation that the connection initiates or a timeout expiration.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I'm making a simple page using Google Maps API 3. My first. One marker
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build
I have some data like this: 1 2 3 4 5 9 2 6

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.