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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:29:20+00:00 2026-05-15T09:29:20+00:00

I am developing an Tcp client in C# and I am using the TcpClient

  • 0

I am developing an Tcp client in C# and I am using the TcpClient class.
I am not able to connect to the server.

Debugging the application I can see that the call to Connect is successfull but after I do this , I check with netstat the status of the connection on both server and client. The result is that the server the connection is ESTABLISHED, but on the client I cannot see any connection to the server in netstat result.

Reading the TcpClient instance I can see that the property Connected is true so it should be fine but when I try to read from the NetworkStream it hangs.

When I say it hangs I mean that the server is sending data but the readline doesn’t get any data at all.

Do you know what could be the issue and some workaround?

Thanks

  • 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-15T09:29:21+00:00Added an answer on May 15, 2026 at 9:29 am

    First, a recommendation: In my experience, TcpClient is best used asynchronously.

    In all my usage of TcpClient though, I’ve never been able to Read a response without first doing a Write with a request. You’ll block forever attempting to synchronously await a response to a request you haven’t sent.

    Expanding on that, sending a request will be done like this:

    TcpClient.GetStream().BeginWrite( tcpMessage, ... );
    

    Which will send the request that’s in tcpMessage, which will be a bytestream produced from a string like this:

    byte[] tcpMessage = httpEncoding.GetBytes( httpMessage );
    

    Which has your request message like this:

    httpMessage = "GET / HTTP/1.1\r\n" + ...;
    

    That sends your request, which causes the server to generate a response which you can then collect like this:

    TcpClient.GetStream().BeginRead( ... );
    

    And you should finally be able to receive something back!
    Even if it’s only a “I didn’t like your request!” response. 8 D

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

Sidebar

Related Questions

I'm developing a server-client application that uses 3 ports [TCP SOCKET .Net 4.0].. So
I am developing an Android application that connects to a TCP server to upload
I am developing an application in C#, using the server-client model, where the server
I'm developing a tcp client using boost::asio to process incoming text, that ends with
I am developing a mobile application that transmit date using TCP protocol ( sockets
While developing an application using gwt in ecliplse crashed. Now the server is running
I'm developing an application that is sending data through tcp/ip I've made my own
i am developing a small TCP Client/Server lib. i am facing this problem when
I am developing a client server app that uses ssl (openssl) to establish a
I'm developing a library which you can use in client or server code. More

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.