Questions tagged [tcp]

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

Transmission Control Protocol (TCP) is a transport layer protocol that provides a connection-oriented data stream service with guaranteed, in-order delivery 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 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 chunks and adds a TCP header to each (creating a TCP segment)
  • Internet: Encapsulates each segment (and splits if necessary) into IP datagram (with source and destination IP address)
  • Link: Encapsulates each datagram (and splits if necessary) and adds physical address (MAC)

There is more information at the Wikipedia article on TCP.

21130 questions
1568
votes
17 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
  • 64,123
  • 15
  • 92
  • 159
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,777
  • 4
  • 20
  • 22
721
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
  • 21,662
  • 20
  • 60
  • 90
428
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
  • 15,721
  • 11
  • 37
  • 44
422
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
  • 16,207
  • 18
  • 81
  • 142
335
votes
14 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,737
  • 6
  • 32
  • 54
320
votes
21 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
  • 65,792
  • 48
  • 164
  • 225
318
votes
16 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,085
  • 4
  • 17
  • 25
316
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
  • 5,568
  • 3
  • 20
  • 29
313
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,141
  • 3
  • 14
  • 4
264
votes
9 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
259
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
  • 37,386
  • 39
  • 142
  • 236
227
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
211
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,141
  • 2
  • 13
  • 4
205
votes
16 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
  • 4,516
  • 5
  • 36
  • 61
1
2 3
99 100