Questions tagged [tcp]

Transmission Control Protocol (TCP) is a transport layer protocol that provides a connection-oriented data stream service with delivery that is guaranteed to be in-order.

Transmission Control Protocol (TCP) is a transport layer protocol that provides a connection-oriented data stream service with delivery that is guaranteed to be in-order on top of the underlying packet-oriented, unreliable IP layer. TCP is referred to as a connection-oriented protocol. This is opposed to UDP, which offers a relatively bare-bones unreliable all-or-nothing delivery of discrete packets and is referred to as a connection-less protocol.

How TCP fits into Internet protocol suite layers (going top to bottom):

  • Application: Encrypts data to be sent or sends data in a specific format (e.g. TLS or HTTPS)
  • Transport: Splits the data into segments and adds a TCP header to each (creating a TCP segment)
  • Internet: Encapsulates each segment (and splits if necessary) into IP packets (with source and destination IP address)
  • Link: Encapsulates each packet (and splits if necessary) and adds physical address (MAC)

The basic definition of TCP is given in RFC 793. There is more information at the Wikipedia article on TCP.

23633 questions
2034
votes
19 answers

Who is listening on a given TCP port on Mac OS X?

On Linux, I can use netstat -pntl | grep $PORT or fuser -n tcp $PORT to find out which process (PID) is listening on the specified TCP port. How do I get the same information on Mac OS X?
pts
  • 80,836
  • 20
  • 110
  • 183
899
votes
2 answers

What does "connection reset by peer" mean?

What is the meaning of the "connection reset by peer" error on a TCP connection? Is it a fatal error or just a notification or related to the network failure?
Franck Freiburger
  • 26,310
  • 20
  • 70
  • 95
879
votes
37 answers

How can I connect to Android with ADB over TCP?

I am attempting to debug an application on a Motorola Droid, but I am having some difficulty connecting to the device via USB. My development server is a Windows 7 64-bit VM running in Hyper-V, and so I cannot connect directly via USB in the guest…
JDM
  • 9,797
  • 4
  • 22
  • 22
458
votes
5 answers

How do multiple clients connect simultaneously to one port, say 80, on a server?

I understand the basics of how ports work. However, what I don't get is how multiple clients can simultaneously connect to say port 80. I know each client has a unique (for their machine) port. Does the server reply back from an available port to…
IamIC
  • 17,747
  • 20
  • 91
  • 154
458
votes
8 answers

What is the largest TCP/IP network port number allowable for IPv4?

What is the highest port number one can use?
username
  • 18,800
  • 11
  • 41
  • 45
423
votes
19 answers

How do I debug error ECONNRESET in Node.js?

I'm running an Express.js application using Socket.io for a chat webapp and I get the following error randomly around 5 times during 24h. The node process is wrapped in forever and it restarts itself immediately. The problem is that restarting…
Samson
  • 2,801
  • 7
  • 37
  • 55
385
votes
22 answers

Artificially create a connection timeout error

I've had a bug in our software that occurs when I receive a connection timeout. These errors are very rare (usually when my connection gets dropped by our internal network). How can I generate this kind of effect artificially so I can test our…
Mark Ingram
  • 71,849
  • 51
  • 176
  • 230
372
votes
18 answers

Test if remote TCP port is open from a shell script

I'm looking for a quick and simple method for properly testing if a given TCP port is open on a remote server, from inside a Shell script. I've managed to do it with the telnet command, and it works fine when the port is opened, but it doesn't seem…
Yanick Girouard
  • 4,711
  • 4
  • 19
  • 26
352
votes
17 answers

Can two applications listen to the same port?

Can two applications on the same machine bind to the same port and IP address? Taking it a step further, can one app listen to requests coming from a certain IP and the other to another remote IP? I know I can have one application that starts off…
nadiv
  • 3,531
  • 3
  • 16
  • 4
339
votes
24 answers

When is it appropriate to use UDP instead of TCP?

Since TCP guarantees packet delivery and thus can be considered "reliable", whereas UDP doesn't guarantee anything and packets can be lost. What would be the advantage of transmitting data using UDP in an application rather than over a TCP stream?…
Jeff L
  • 6,108
  • 3
  • 23
  • 29
292
votes
3 answers

What is the theoretical maximum number of open TCP connections that a modern Linux box can have

Assuming infinite performance from hardware, can a Linux box support >65536 open TCP connections? I understand that the number of ephemeral ports (<65536) limits the number of connections from one local IP to one port on one remote IP. The tuple…
fadedbee
  • 42,671
  • 44
  • 178
  • 308
289
votes
6 answers

Simulate delayed and dropped packets on Linux

I would like to simulate packet delay and loss for UDP and TCP on Linux to measure the performance of an application. Is there a simple way to do this?
Alec
240
votes
18 answers

java.net.ConnectException: Connection refused

I'm trying to implement a TCP connection, everything works fine from the server's side but when I run the client program (from client computer) I get the following error: java.net.ConnectException: Connection refused at…
Samantha Catania
  • 5,116
  • 5
  • 39
  • 69
233
votes
2 answers

What is the difference between HTTP 1.1 and HTTP 2.0?

HTTP/1.1 has served the Web well for more than fifteen years, but its age is starting to show. Can anybody explain what is the main difference between HTTP 1.1 and 2.0? Is there any change in the transport protocol?
user1968030
233
votes
10 answers

Maximum packet size for a TCP connection

What is the maximum packet size for a TCP connection or how can I get the maximum packet size?
Alexa
  • 2,361
  • 2
  • 14
  • 4
1
2 3
99 100