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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:46:40+00:00 2026-06-01T00:46:40+00:00

I’m working on a simple project for my Data Communications class. I predicted it

  • 0

I’m working on a simple project for my Data Communications class. I predicted it would take me two hours max but it’s my first time writing software that makes a connection to the web and my first time working with C# and I’m hitting a pretty major road bump.

I establish a connection to the server but I appear to get absolutely no feedback from the server. Here is the code I am executing to establish a connection:

TcpClient conn = new TcpClient();
conn.Connect(host, port);
StreamReader reader = new StreamReader(conn.GetStream());
StreamWriter writer = new StreamWriter(conn.GetStream());
Console.WriteLine(conn.Connected);   //This line does print true.
//Console.WriteLine(reader.ReadLine());     I thought I'd get a message when I initially
//connected to the server but this line would hang

That is where I establish a connection. According to the project’s specifications, inputting a 0 should prompt the server to return a ticket number. so I have the following code:

writer.WriteLine("0");
return reader.ReadLine();

The prgram hangs when trying to execute reader.ReadLine(). I’ve tried other methods in reader but it seems to hang on all of them. I’ve looked at plenty of code samples with setups similar to mine. Can anyone see any issues with my code? I don’t think its a problem with the server. My professor said something about using a unix command “telnet [host] [port]” and I used the same host and port for this code. I’m developing this on a Windows 7 machine. I apologize for my ignorance in both C# and network programming.

If I left out any dire information, please let me know. As this is my first time dealing with this I’d imagine I left out something urgent.

Thanks a ton you guys!

  • 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-01T00:46:41+00:00Added an answer on June 1, 2026 at 12:46 am

    You need to make sure that the writer (and the stream that it wraps) flushes it’s output:

    writer.WriteLine("0");
    writer.Flush();
    return reader.ReadLine();
    

    Streams often buffer information to optimize I/O, because many I/O devices are more efficient with larger streams of data than short bursts. Your “0” is likely just too little data to cause the stream to actually send anything. This applies to things like disk I/O (writing files) as well.

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

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
I am doing a simple coin flipping experiment for class that involves flipping a
I want to construct a data frame in an Rcpp function, but when I
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.