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

Is there MS SQL Server function that counts the number of times a particular
Is there any way to add dates/times that will be portable between Oracle and
In Javascript is there a function that returns the number of times that a
In a recent discussion on ORMs for webapps someone mentioned that there are times
I have a class that refers to UiApplication.getUiApplication() multiple times, would there be any
There are times that I automagically create small shell scripts from Python, and I
There are often times that I want to execute a command on all files
There are many times that I get compile errors when I use char* instead
I love smartcase , but there are times that I'd like to turn it
i have experienced many times that error. There is no such error in FF

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.