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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:38:41+00:00 2026-05-13T17:38:41+00:00

I tried to send/receive data by using TcpClient. I did two experiments and found

  • 0

I tried to send/receive data by using TcpClient. I did two experiments and found something interesting.

I setup the TcpListener in a server in Japan and the TcpClient in UK. I kept sending 500 bytes to the TcpListener and when TcpListener sends 10KB back to the TcpClient. I kept this send/receive looping for 500 times in each experiment.

Experiment 1:

In every send/receive loop, I create a brand new TcpClient (the time ticks from just before the creation) and send/receive

Experiment 2:

For all loops, I only have one TcpClient, and it keeps the connection with TcpListener and do the send/receive for 500 times.

Result:

The average value of the time cost for one loop:

E1: 1.8 seconds, E2: 0.49 seconds.

I am quite surprised by this result. So keeping connection for constant send/receive can save that lots of time??? nearly 2/3 of the time.

Is this true???

Thanks

====new====

@Jon Skeet, @dbemerlin, Thanks for the reply. I guessed the Tcp handshakes take some time tool.

So I did Experiment 3.

I setup a HttpListener as the server and use a WebClient to send/receive, the data sizes are exactly the same. And every time I used a new WebClient to send/receive between UK and Japan.

The result is 0.86 (average from 500 times loop, i.e., send/receive).

I assume that WebClient / HttpLisener themselves are Tcp, right? How can they be faster than raw TcpClient/TcpListener in my experiments??

THanks again

  • 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-13T17:38:42+00:00Added an answer on May 13, 2026 at 5:38 pm

    This isn’t particularly surprising, but it’s not the cost of creating the object – it’s the cost of setting up a TCP connection, with handshakes etc.

    If you can do a lot of work over a single connection, that’s more efficient than setting up a new connection each time. To put it in real world terms, consider a phone conversation between two people.

    Efficient scenario: you dial the number, they pick up, you talk, they reply, you talk, they reply etc.

    Inefficient scenario: you dial the numebr, they pick up, you talk, they reply, you hang up. You then immediately dial the number again, they pick up, you talk, they reply, you hang up etc.

    Imagine doing the latter in reality! You’d go crazy very quickly…

    EDIT: By default, WebClient will leave a hanging connection open to the web server. If you force the connections to be reset (basically disable KeepAlive) then you’ll see the slow behaviour again.

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

Sidebar

Ask A Question

Stats

  • Questions 321k
  • Answers 321k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You're currently just grouping by the ID. Instead, as per… May 14, 2026 at 12:41 am
  • Editorial Team
    Editorial Team added an answer I think a better solution would be to use CGRectContainsPoint:… May 14, 2026 at 12:41 am
  • Editorial Team
    Editorial Team added an answer Most probably you are having a linking error because: void… May 14, 2026 at 12:41 am

Related Questions

I have a very simple Winsock2 TCP client - full listing below - which
I am doing some socket programming in C, and trying to wrestle with byte
Here's some background on what I'm trying to do: Open a serial port from
I recently purchased a Magic Mouse. It is fantastic and full of potential. Unfortunately,
I'm writing an app for WM that handles incoming SMS events. I tried making

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.