How can a web server handle multiple user’s incoming requests at a time on a single port (80)?

A port is just a magic number. It doesn’t correspond to a piece of hardware. The server opens a socket that ‘listens’ at port 80 and ‘accepts’ new connections from that socket. Each new connection is represented by a new socket whose local port is also port 80, but whose remote IP:port is as per … Read more

HTTP Keep Alive and TCP keep alive

I know this is an old question, but still: HTTP Keep-Alive is a feature that allows HTTP client (usually browser) and server (webserver) to send multiple request/response pairs over the same TCP connection. This decreases latency for 2nd, 3rd,… HTTP request, decreases network traffic and similar. TCP keepalive is a totally different beast. It keeps … Read more

Setting TIME_WAIT TCP

A TCP connection is specified by the tuple (source IP, source port, destination IP, destination port). The reason why there is a TIME_WAIT state following session shutdown is because there may still be live packets out in the network on their way to you (or from you which may solicit a response of some sort). … Read more

Nginx TCP forwarding based on hostname

This is now possible with the addition of the ngx_stream_ssl_preread module added in Nginx 1.11.5 and the ngx_stream_map module added in 1.11.2. This allows Nginx to read the TLS Client Hello and decide based on the SNI extension which backend to use. stream { map $ssl_preread_server_name $name { vpn1.app.com vpn1_backend; vpn2.app.com vpn2_backend; https.app.com https_backend; default … Read more

How to see what is reserving ephemeral port ranges on Windows?

Investigate and Free the Ports It appears that Hyper-V reserves random ports (or something Hyper-V related at least). Use netsh int ip show excludedportrange protocol=tcp to confirm that the ports that aren’t working are in the output. This has worked for me to free the ports up. It doesn’t seem intrusive to me (25 thumbs … Read more

Using pipe() in Node.js net

The pipe() function reads data from a readable stream as it becomes available and writes it to a destination writable stream. The example in the documentation is an echo server, which is a server that sends what it receives. The socket object implements both the readable and writable stream interface, so it is therefore writing … Read more

When is “java.io.IOException:Connection reset by peer” thrown?

java.io.IOException: Connection reset by peer The other side has abruptly aborted the connection in midst of a transaction. That can have many causes which are not controllable from the server side on. E.g. the enduser decided to shutdown the client or change the server abruptly while still interacting with your server, or the client program … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)