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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:09:04+00:00 2026-06-01T18:09:04+00:00

Ive got a TCP client stream that is being read via async call NetworkStream.BeginRead

  • 0

Ive got a TCP client stream that is being read via async call NetworkStream.BeginRead (passing an async call back delegate). The problem is to detect when the connection is down. Currently if the connection is cut the BeginRead call just disappears into the ether – the call back is just not called. If the app try a send on the stream while its down this does trigger the callback and NetworkStream.EndRead throws an exception – this is OK – but if no send is issued then app just sits in the dark unware that connection is down.

Initially I saw that NetworkStream.ReadTimout was not set (i.e. was default Timout.Infinite) – but setting this (to, say, 3000ms) didn’t help. [Edit: MSDN doc clearly states that ReadTimeout only applys to the syncronous Read call not the asyn BeginRead – I should have checked that more carefully earlier 🙁 ]

How to detect that client connection has failed?

Do I have to poll the underlying socket as shown in this SO question?

In addition: When the connection is physically re-established the callback still doesn’t get called – we just sit waiting in the ether until we try a send.

  • 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-01T18:09:05+00:00Added an answer on June 1, 2026 at 6:09 pm

    I ended up having to change from a TcpClient async BeginRead to a syncronous Read with a timeout on a dedicated read Thead.

    This enabled me to raise an event when the timeout was pulled due to no data on the stream.

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

Sidebar

Related Questions

I've got a TCP server and client written in C that opens up a
I've this nice ASYNC tcp stream class that I'm using to connect to perl
ive got an object that looks like this with print_r(): SimpleDOM Object ( [0]
Ive got this problem: Line 20 (LOOT_FromContainer(container) I need that to use as Invoke
Ive got a jquery app that has several grids (jqgrid) in defferent tabs. Below
Right now I've got a simple TCP server/client. I have it set up so
I've got a TCP socket which reads data. When an error occurs when reading
Ive got the following code which I hacked together from website examples. It works
Ive got a view helper in library/my/view/helper/gravatar and so in any view I can
Ive got the following html setup: <div id=div1> <div id=content1>blaat</div> <div id=content1>blaat2</div> </div> it

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.