1# Asio SSL client/server example 2 3Simple Asio client and server with SSL/TLS transport 4 5## How to Use Example 6 7### Hardware Required 8 9This example can be executed on any ESP platform board. No external connection is required, it is recommended though 10to connect to internet or a local network via WiFi or Ethernet to easily exercise features of this example. 11 12### Configure the project 13 14* Open the project configuration menu (`idf.py menuconfig`) 15* Configure Wi-Fi or Ethernet under "Example Connection Configuration" menu. See "Establishing Wi-Fi or Ethernet Connection" section in [examples/protocols/README.md](../../README.md) for more details. 16* Enable the ASIO client and set server's host name to examine client's functionality. 17The ASIO client connects to the configured server and sends default payload string "GET / HTTP/1.1" 18* Enable the ASIO server to examine server's functionality. The ASIO server listens to connection and echos back what was received. 19 20### Build and Flash 21 22Build the project and flash it to the board, then run monitor tool to view serial output: 23 24``` 25idf.py -p PORT flash monitor 26``` 27 28(To exit the serial monitor, type ``Ctrl-]``.) 29 30See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects. 31 32## Example Output 33 34### Client connecting to public server 35 36The below output illustrates the client connecting to a public https server. 37 38``` 39I (1267) example_connect: Waiting for IP(s) 40I (2587) wifi:new:<11,0>, old:<1,0>, ap:<255,255>, sta:<11,0>, prof:1 41I (3367) wifi:state: init -> auth (b0) 42I (3377) wifi:state: auth -> assoc (0) 43I (3387) wifi:state: assoc -> run (10) 44I (3397) wifi:security type: 3, phy: bgn, rssi: -49 45I (3397) wifi:pm start, type: 1 46I (3457) wifi:AP's beacon interval = 102400 us, DTIM period = 1 47I (4747) example_connect: Got IPv6 event: Interface "example_connect: sta" address: fe80:0000:0000:0000:260a:xxxx:xxxx:xxxx, type: ESP_IP6_ADDR_IS_LINK_LOCAL 48I (5247) esp_netif_handlers: example_connect: sta ip: 192.168.32.69, mask: 255.255.252.0, gw: 192.168.32.3 49I (5247) example_connect: Got IPv4 event: Interface "example_connect: sta" address: 192.168.32.69 50I (5257) example_connect: Connected to example_connect: sta 51I (5257) example_connect: - IPv4 address: 192.168.32.69 52I (5267) example_connect: - IPv6 address: fe80:0000:0000:0000:260a:xxxx:xxxx:xxxx, type: ESP_IP6_ADDR_IS_LINK_LOCAL 53W (5277) esp32_asio_pthread: pthread_condattr_setclock: not yet supported! 54W (5297) esp32_asio_pthread: pthread_condattr_setclock: not yet supported! 55Reply: HTTP/1.1 200 OK 56D 57``` 58### Both server and client enabled 59 60The below output demonstrates the client connecting to the ASIO server via loopback interface, so no WiFi, nor Ethernet connection 61was established. 62``` 63I (0) cpu_start: App cpu up. 64I (495) heap_init: Initializing. RAM available for dynamic allocation: 65I (502) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM 66I (508) heap_init: At 3FFB5400 len 0002AC00 (171 KiB): DRAM 67I (515) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM 68I (521) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM 69I (527) heap_init: At 4008BB80 len 00014480 (81 KiB): IRAM 70I (534) cpu_start: Pro cpu start user code 71I (556) spi_flash: detected chip: gd 72I (556) spi_flash: flash io: dio 73W (556) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header. 74I (566) cpu_start: Starting scheduler on PRO CPU. 75I (0) cpu_start: Starting scheduler on APP CPU. 76I (600) example_connect: Waiting for IP(s) 77W (600) esp32_asio_pthread: pthread_condattr_setclock: not yet supported! 78W (1610) esp32_asio_pthread: pthread_condattr_setclock: not yet supported! 79W (1610) esp32_asio_pthread: pthread_condattr_setclock: not yet supported! 80Server received: GET / HTTP/1.1 81 82 83Reply: GET / HTTP/1.1 84``` 85See the README.md file in the upper level 'examples' directory for more information about examples. 86