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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:32:47+00:00 2026-05-22T20:32:47+00:00

There are times that the recByte will fail to receive response even though the

  • 0

There are times that the recByte will fail to receive response even though the server
did reply because the server wasn’t fast enough. Which if happened I use

catch (System.IO.IOException ioe)

to prevent the error, but are there possible alternatives that allow the client to wait a bit longer?
I did try

clientStream.ReadTimeout = 20000;

but it didn’t work

TcpClient Client = new TcpClient();
Client.Connect(ipaddress, portnum);

NetworkStream clientStream = Client.GetStream();

byte[] buffer = themessagetosent;
clientStream.Write(buffer, 0, buffer.Length);

byte[] recByte = theresponse;
clientStream.Read(recByte, 0, recByte.Length);
  • 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-22T20:32:48+00:00Added an answer on May 22, 2026 at 8:32 pm

    You need to increase timeout for the tcpClient, not for the stream. Also, probably want to increase timeout for both send and receive, and probably to more than just 2 sec.

    var client = new TcpClient { SendTimeout = 10000, ReceiveTimeout = 10000 };
    

    I believe if you look at inner exception in IOException, you will see SocketException inside. Look at error code to find out what exactly is happening.

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

Sidebar

Related Questions

Are there any products that will decrease c++ build times? that can be used
There are numerous times you have an interface that accepts similar type arguments that
I've got m2eclipse plugin installed and there's no problem syncing compile time dependencies that
I am aware that in .NET there are three timer types (see Comparing the
Is there an algorithm that is more time efficient than O(n^2) for detecting cycles
Through profiling I've discovered that the sprintf here takes a long time. Is there
What are the differences between #import and #include in Objective-C and are there times
There are times when I want to use mootools for certain things and Prototype
There are times when I want to test new code from the forums or
I have a solution with 50 projects. There are times when I just modify

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.