diff --git a/404.html b/404.html index 25d594856..b8b919c9e 100644 --- a/404.html +++ b/404.html @@ -97,7 +97,7 @@ diff --git a/index.html b/index.html index 06645430b..399230bf0 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ - Quinn introduction - Quinn + QUINN Introduction - Quinn @@ -95,7 +95,7 @@ diff --git a/print.html b/print.html index bc84ae0f0..5f4aaf7d0 100644 --- a/print.html +++ b/print.html @@ -97,7 +97,7 @@ @@ -389,6 +389,78 @@ builder.add_certificate_authority(certificate)?;

This is the only thing you need to do for your client to trust a server certificate.



Next, let's have a look at how to set up a connection.

+

Connection Setup

+

In the previous chapter we looked at how to configure a certificate. +This aspect is omitted in this chapter to prevent duplication. +But remember that this is required to get your Endpoint up and running. +This chapter explains how to set up a connection and prepare it for data transfer.

+

It all starts with the Endpoint struct, this is the entry point of the library.

+

Example

+

Let's start by defining some constants.

+

+#![allow(unused)]
+fn main() {
+static SERVER_NAME: &str = "localhost";
+
+fn client_addr() -> SocketAddr {
+    "127.0.0.1:5000".parse::<SocketAddr>().unwrap()
+}
+
+fn server_addr() -> SocketAddr {
+    "127.0.0.1:5001".parse::<SocketAddr>().unwrap()
+}
+}
+
+

The EndpointBuilder should be used to configure an endpoint. It is also possible to provide Quinn with an initialized socket via with_socket().

+

Server

+

First, the server endpoint should be bound to a socket. +The bind() method, which can be used for this, returns a tuple containing the Endpoint and Incoming types. +The Endpoint type can be used to start outgoing connections, and the Incoming type can be used to listen for incoming connections.

+

+#![allow(unused)]
+fn main() {
+async fn server() -> anyhow::Result<()> {
+    let mut endpoint_builder = Endpoint::builder();
+    // Configure this endpoint as a server by passing in `ServerConfig`.
+    endpoint_builder.listen(ServerConfig::default());
+
+    // Bind this endpoint to a UDP socket on the given server address. 
+    let (endpoint, mut incoming) = endpoint_builder.bind(&server_addr())?;
+
+    // Start iterating over incoming connections.
+    while let Some(conn) = incoming.next().await {
+        let mut connection: NewConnection = conn.await?;
+
+        // Save connection somewhere, start transferring, receiving data, see DataTransfer tutorial.
+    }
+
+    Ok(())
+}
+}
+
+

Client

+

The client needs to connect to the server using the connect(server_name) method.
+The SERVER_NAME argument is the DNS name, matching the certificate configured in the server.

+

+#![allow(unused)]
+fn main() {
+async fn client() -> anyhow::Result<()> {
+    let mut endpoint_builder = Endpoint::builder();
+
+    // Bind this endpoint to a UDP socket on the given client address.
+    let (endpoint, _) = endpoint_builder.bind(&client_addr())?;
+
+    // Connect to the server passing in the server name which is supposed to be in the server certificate.
+    let connection = endpoint.connect(&server_addr(), SERVER_NAME)?.await?;
+
+    // Start transferring, receiving data, see data transfer page.
+
+    Ok(())
+}
+}
+
+



+

Next up, let's have a look at sending data over this connection.

The QUIC protocol

QUIC is a general-purpose network protocol built on top of UDP. The protocol is still under development and standardized by the IETF. diff --git a/quic.html b/quic.html index b902b8984..107f30634 100644 --- a/quic.html +++ b/quic.html @@ -95,7 +95,7 @@

@@ -189,7 +189,7 @@ One thing is for sure, QUIC has many great potentials and will serve us in the f