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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:09:38+00:00 2026-06-16T02:09:38+00:00

I am setting timeout for a TcpClient using TcpClient.ReceiveTimeout property. When the TcpClient.Read() method

  • 0

I am setting timeout for a TcpClient using TcpClient.ReceiveTimeout property. When the TcpClient.Read() method throws an exception (“connected party did not properly respond after a period of time”) -naturally- after TcpClient.ReceiveTimeout miliseconds, TcpClient.Connected begins to return false.

Is that normal? Is there a way to prevent this? I want to get the exception but keep the connection open.

  • 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-16T02:09:39+00:00Added an answer on June 16, 2026 at 2:09 am

    That is normal behavior.

    You can set an infinite receive timeout to avoid this situation (infinite is the default. You can explicitly set it with 0 as the ReceiveTimeout property). However, that would cause problems in program responsiveness if there really is never a client on the other end. It may be better to log the connection failure and then create a new connection, depending on your exact use case.

    Here’s the pattern I would typically use (pseudo-codeish. The connection method would normally be inline with exception handling):

    while (!done)
    {
        // Try to connect with a reasonable ReceiveTimeout
        connected = EstablishTheConnectionAndHandleAnyException();
        if (connected)
        {
            // Do useful work
            done = true;
        }
        else
        {
            // Receive timeout
            // If interactive, give the user an opportunity to abort
            //    by setting done = true
            // At least log the situation
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Q1 I’ve read that when setting the timeout of an authentication cookie, we should
I am using ASP.NET Forms Authentication and currently setting the timeout value in Web.config.
Is there any other reasoning other than the timeout setting in the web.config not
I'm setting the timeout value of an NSMutableURLRequest in code as follows: request.timeoutInterval =
Setting onchange event for CheckBoxList using the following code doesn't work. chkListUserGroup.Attributes.Add(onchange, document.forms[0].isRecordModified.value='true';); How
Using a StreamWriter to write to a NetworkStream , and a StreamReader to read
Possible Duplicate: jquery $.ajax timeout setting The timeout works, but when the timeout occurs,
From time to time our server throw this well-known exception: Timeout expired. The timeout
If you are using it for simple purposes, WebClient is enough. Absence of Timeout
In IIS 6 (and other versions too afaik), there is a Session Timeout setting

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.