0

Here is my understanding of how a client-server HTTP server works.

  1. The client creates a TCP socket connection to connect to the server and sends data.
  2. The server creates a TCP socket connection to listen for incoming requests.

So it looks like both the client and the server need to agree on the use of the Transport protocol to use (in this case TCP). But if we want a website to work over UDP/QUIC protocol then we need both the client and the server to create a UDP socket connection. But some websites use TCP and others use UDP...

So does it mean it would need to look like this?

if (URI == 'https://www.google.com') {
  // Website that works over UDP
  client.create.UDP.socket
  client.sendData

  server.create.UDP.socket
  server.receive.data
} else {
  // Website that works over TCP
  client.create.TCP.socket
  client.sendData

  server.create.TCP.socket
  server.receive.data
}

So the client needs to keep a record of which website uses TCP and which websites use UDP/QUIC and create that kind of socket to communicate with it?

Liga
  • 135
  • 2
  • 12
  • Exactly where are you writing this piece of code? HTTP is implemented on TCP/IP but it also works over UDP and QUIC. You have to define the port for UDP protocol properly. – Nazia Jahan Trisha Jan 08 '20 at 10:57
  • Well Google works on TCP port 443 and also on QUIC/UDP port 443 but how does it work? – Liga Jan 08 '20 at 10:59

1 Answers1

2

HTTP is an encoding for verbs and responses. It can run across any transport, TCP, QUIC, SCTP. QUIC is optimized for HTTP/2, but it does work as a generic transport.

A problem is that https:// URLs imply TCP, from a strict reading of RFC 7230. So, the Alt-Svc header in an initial TCP response offers quic or upgrades to http 2 or 3. curl's notes on HTTP Alternative Services may be helpful.

So when running a web server with this QUIC thing, you still need to listen on TCP so user agents can upgrade. Not using it would not standards compliant and have implementation issues, per a QUIC working group discussion.

John Mahowald
  • 32,050
  • 2
  • 19
  • 34