Questions tagged [tcp]

The Transport Control Protocol (TCP) is a low-level part of the protocol stack used by the Internet. It sits directly above the IP layer and is responsible for making sure that dropped packets are resent.

TCP provides reliable, ordered, error-checked delivery of a stream of octets between programs running on computers connected to a local area network, intranet or the public Internet. It resides at the transport layer.

Web browsers use TCP when they connect to servers on the World Wide Web, and it is used to deliver email and transfer files from one location to another.

Applications that do not require the reliability of a TCP connection may instead use the connectionless User Datagram Protocol (UDP), which emphasizes low-overhead operation and reduced latency rather than error checking and delivery validation.

See: http://en.wikipedia.org/wiki/Transmission_Control_Protocol

611 questions
151
votes
8 answers

Simple way to create a tunnel from one local port to another?

I have a development server, which is only accessible from 127.0.0.1:8000, not 192.168.1.x:8000. As a quick hack, is there a way to set up something to listen on another port (say, 8001) so that from the local network I could connect…
waitinforatrain
  • 1,615
  • 2
  • 11
  • 7
117
votes
5 answers

Determining what process is bound to a port

I know that using the command: lsof -i TCP (or some variant of parameters with lsof) I can determine which process is bound to a particular port. This is useful say if I'm trying to start something that wants to bind to 8080 and some else is…
user5721
114
votes
2 answers

How does tcp-keepalive work in ssh?

I am trying to code a shell-script that uses a ssh-connection for doing "heartbeats". I want to terminate the client- and server-side of that connection after a certain timeout (after the connection drops). What I found so far: TCPKeepAlive yes/no…
Nils
  • 18,202
  • 11
  • 46
  • 82
96
votes
10 answers

How to terminate dead connections from the command line without restarting server

I have some dead connections in an application which enter a hanged state if the client machine is dead. One of the connections is shown as ->192.168.1.214:49029 (ESTABLISHED) Is there a way to terminate these connections from the Linux command…
Vivek Goel
  • 1,273
  • 1
  • 13
  • 11
80
votes
7 answers

Allowing a regular user to listen to a port below 1024

I need to allow a non-root user to run a server listening on port tcp/80. Is there any way to do this?
peoro
  • 3,658
  • 3
  • 32
  • 32
79
votes
6 answers

How to create a TCP listener?

Introduction: I have created a bash function that is able to check whether a port is available and increments it by 1 if false until a certain maximum port number. E.g., if port 500 is unavailable then the availability of 501 will be checked until…
030
  • 1,527
  • 2
  • 17
  • 33
70
votes
3 answers

Is it possible to connect to TCP port 0?

Listening to TCP port 0 allocates a free port number on the system for me. But what happens when I try to connect to TCP port 0? The obvious answer is: "It doesn't work": $ nc localhost 0 nc: port number too small: 0 Where in the…
nh2
  • 1,611
  • 2
  • 14
  • 22
68
votes
1 answer

Why are the first 1024 ports restricted to the root user only?

This is more idle curiosity than anything else. A friend of mine asked me 'which port range is it that only root can use under Linux?' I told him 0-1024 were restricted. Then he asked my why it was so and... I was at a loss. No idea whatsoever. Is…
Andrew Lambert
  • 2,358
  • 1
  • 16
  • 17
68
votes
4 answers

How to connect ssh from a specified port?

I know how to connect 'to' a certain port using ssh. ssh user@remotehostip -p XXX Is there a way to establish ssh from the port which my local computer will be using?
kwagjj
  • 2,309
  • 6
  • 22
  • 29
63
votes
2 answers

Performance of unix sockets vs TCP ports

For example on php-fpm: #listen = 127.0.0.1:9000 listen = /var/run/php-fpm/php-fpm.sock Is there any major performance differences between using unix socket-based listeners over TCP ports? (Not just for PHP but in general. Is it different for each…
Jason
  • 1,714
  • 5
  • 25
  • 30
58
votes
3 answers

Can TCP provide more than 65535 ports?

Is it possible to setup a Linux system so that it provides more than 65,535 ports? The intent would be to have more than 65k daemons listening on a given system. Clearly there are ports being used so this is not possible for those reasons, so…
slm
  • 363,520
  • 117
  • 767
  • 871
57
votes
1 answer

Connecting to IP 0.0.0.0 succeeds. How? Why?

We are serving a port on localhost and want to check in another process if the port is available. Due to a bug in our code, it is actually trying to connect to the IP 0.0.0.0:, and for some reason it succeeds -- as strace…
erikbstack
  • 940
  • 2
  • 9
  • 16
45
votes
2 answers

how to check rx ring, max_backlog, and max_syn_backlog size

Quite often in the course of troubleshooting and tuning things I find myself thinking about the following Linux kernel settings: net.core.netdev_max_backlog net.ipv4.tcp_max_syn_backlog net.core.somaxconn Other than fs.file-max,…
Colin Hostert
  • 553
  • 1
  • 5
  • 4
43
votes
1 answer

Why are IPv4 TCP connections showing as tcp6?

Here's the output of netsat -tupn on my Debian Jessie server: Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 10.0.0.12:445 …
Torvero
  • 543
  • 1
  • 4
  • 7
41
votes
5 answers

How to close ports in Linux?

I have some question in closing port, I think I got some strange things. When I use execute nmap --top-ports 10 192.168.1.1 it shows that 23/TCP port is open. But when I execute nmap --top-ports 10 localhost it show that 23/tcp port is…
user74080
  • 513
  • 1
  • 4
  • 5
1
2 3
40 41