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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:26:13+00:00 2026-05-11T16:26:13+00:00

From reading a few questions and answers here, it seems that a telnet stream

  • 0

From reading a few questions and answers here, it seems that a telnet stream never really closes. Using DataAvailable() will not return.

I’ve inherited some code that took a very very long time to complete and we thought it was the telnet server that was the problem. However, there is a byte[32757] which the code tries to store the response of the telnet server in.

Something like the following:

Byte byteArray[] = new Byte[32757];
TcpClient sock = new TcpClient();
sock.GetStream().read(byteArray, 0 byteArray.length);

If there isn’t 32757 bytes or more, I’m assuming this code waits until enough empty packets are sent to make up the size of the byte array. Is this correct?

Is there a way to check if the telnet server has finished sending everything it wants to? There is no visible terminating char or string in each ‘page’ of the telnet session.

I was thinking a way to correct this code is to read a few bytes at a time, add that to a string, check the string for a terminating character or set of chars and return if found. Otherwise, read more bytes, add that to the string, and check again.

Suggestions?

  • 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-11T16:26:13+00:00Added an answer on May 11, 2026 at 4:26 pm

    No, Stream.Read doesn’t generally wait until it’s read everything, and it’s even less likely to for a network stream. It will read whatever data is available, or block until there’s some data available, but that’s all.

    There’s no real concept of the server “finishing” sending what it’s going to send, unless either:

    • a) it tells you in advance how much it’s going to send
    • b) it indicates when it’s finished with some sort of termination data
    • c) it closes the connection

    You may want to use a timer of some sort to achieve an effect of “keep reading until one of the reads takes more than 5 seconds”. Note that the read would still be happening though – you’d just pick that time to update the UI (or whatever). It’s quite a tricky topic, and you really need to be very clear in your own mind (and docs!) what you want to do, and which thread’s going to handle what.

    An alternative is to set a read timeout on the TcpClient, but I don’t have experience of that. You’d probably just need to use TcpClient.ReceiveTimeout and then handle the resulting IOException appropriately when reading, but I don’t have any advice to offer on it.

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

Sidebar

Related Questions

It's clear from reading through threads that I can call a PHP function using
Seems like this might be easy, but from reading other SO answers there are
I've been reading here a few questions regarding the use of unit testing to
From reading the NERDTree documentation on github, I've learned that I can do such
From reading the Apple Docs on Core Data, I've learned that you should not
From reading the RFC it appears that CID can/must only contain characters from the
I know from reading the assoc. Google group that there is not currently an
I am starting to learn AspectJ. From reading tutorials, I know that I can
I am currently writing a distributed system using hazelcast. I have a few questions
Right, i'm new to PHP and mySQL, but i've got a few questions that

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.