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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:33:31+00:00 2026-06-05T02:33:31+00:00

Out of curiosity, how much data is actually sent when establishing a connection to

  • 0

Out of curiosity, how much data is actually sent when establishing a connection to a port (using Java sockets). Is it the size of a Socket object? SocketConnection object?

  • 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-05T02:33:33+00:00Added an answer on June 5, 2026 at 2:33 am

    Your understanding of TCP network connections seems to conflate them with electrical circuits. (Understandable, given your background.)

    From a physical standpoint, there’s no such thing as a connection, only data packets. Through the TCP protocol, two devices agree to establish a logical (that is, software) connection. A connection is established by a client first sending data to the remote host (SYN), the server sending data back to the client (SYN-ACK), and the client sending a final acknowledgement (ACK). All of this negotation necessarily consumes bandwidth, and when you terminate a connection, you must negotiate a completely new connection to begin sending data again.

    For example, I’ll connect from my machine to a local web server, 192.168.1.2:80.

    First, my machine sends a TCP SYN. This sends 66 bytes over the wire: (headers deliniated with |)

    0000  00 24 8c a9 4c b4 00 1e  68 66 20 79 08 00|45 00   .$..L... hf y..E.
    0010  00 34 53 98 40 00 80 06  00 00 c0 a8 01 0b c0 a8   .4S.@... ........
    0020  01 02|36 0a 00 50 09 ef  3a a7 00 00 00 00 80 02   ..6..P.. :.......
    0030  20 00 50 c8 00 00 02 04  05 b4 01 03 03 02 01 01    .P..... ........
    0040  04 02                                              ..               
    

    The first 14 bytes are the Ethernet frame, specifying that this packet’s destination MAC address. This will typically be an upstream router, but in this case, the server happens to be on the same switch, so it’s the machine’s MAC address, 00:24:8c:a9:4c:b4. The source (my) MAC follows, along with the payload type (IP, 0x0800). The next 20 bytes are the IPv4 headers, followed by 32 bytes of TCP headers.

    The server responds with a 62-byte SYN-ACK:

    0000  00 1e 68 66 20 79 00 24  8c a9 4c b4 08 00|45 00   ..hf y.$ ..L...E.
    0010  00 30 69 b9 40 00 80 06  0d b1 c0 a8 01 02 c0 a8   .0i.@... ........
    0020  01 0b|00 50 36 0a d3 ae  9a 73 09 ef 3a a8 70 12   ...P6... .s..:.p.
    0030  20 00 f6 9d 00 00 02 04  05 b4 01 01 04 02          ....... ......  
    

    Again, 14 bytes of Ethernet headers, 20 bytes of IP headers, and 28 bytes of TCP headers. I send an ACK:

    0000  00 24 8c a9 4c b4 00 1e  68 66 20 79 08 00|45 00   .$..L... hf y..E.
    0010  00 28 53 9a 40 00 80 06  00 00 c0 a8 01 0b c0 a8   .(S.@... ........
    0020  01 02|36 0a 00 50 09 ef  3a a8 d3 ae 9a 74 50 10   ..6..P.. :....tP.
    0030  fa f0 83 78 00 00                                  ...x..           
    

    14 + 20 + 20 = 54 bytes over the wire (this is the smallest possible TCP packet size, by the way – the SYN and SYN-ACK packets were larger because they included options).

    This adds up to 182 bytes over the wire to establish a connection; now I can begin sending actual data to the server:

    0000  00 24 8c a9 4c b4 00 1e  68 66 20 79 08 00 45|00   .$..L... hf y..E.
    0010  01 9d 53 9d 40 00 80 06  00 00 c0 a8 01 0b c0 a8   ..S.@... ........
    0020  01 02|36 0a 00 50 09 ef  3a a8 d3 ae 9a 74 50 18   ..6..P.. :....tP.
    0030  fa f0 84 ed 00 00|47 45  54 20 2f 20 48 54 54 50   ......GE T / HTTP
    0040  2f 31 2e 31 0d 0a 48 6f  73 74 3a 20 66 73 0d 0a   /1.1..Ho st: fs..
    ...
    

    14 Ethernet + 20 IP + 20 TCP + data, in this case HTTP.


    So we can see that it costs ~182 bytes to establish a TCP connection, and an additional 162-216 bytes to terminate a TCP connection (depending on whether a 4-way FIN ACK FIN ACK or more common 3-way FIN FIN-ACK ACK termination handshake is used), adding up to nearly 400 bytes to “pulse” a connection by disconnecting and reconnecting.

    Compared to the 55 bytes you’d use to send one byte of data over an already established connection, this is obviously wasteful.

    What you want to do is establish one connection and then send data as-needed. If you’re really bandwidth constrained, you could use UDP (which requires no handshaking at all and has an overhead of only 14 Ethernet + 20 IP + 8 UDP bytes per packet), but then you face the problem of using an unreliable transport, and having to handle lost packets on your own.

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

Sidebar

Related Questions

Out of curiosity, why are sometimes multiple Java .class files generated for a class
Out of curiosity I've been playing with jQuery to determine the browser's screen size,
Just out of curiosity i wanted to make something similar to what pretty much
This isn't much of a problem, really, it's entirely out of curiosity. For a
Out of curiosity im interesting in finding out which ranges are reserved for localhost
Out of curiosity, what is the reasoning behind typeof not being a regular method
Out of curiosity, I wonder what can people do with parsers, how they are
Out of curiosity about reverse engineering, I am thinking of writing a simple program
Out of curiosity, I've been reading up a bit on the field of Machine
Out of curiosity is it possible to temporarily add a character that should be

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.