{"id":29013889,"url":"https://github.com/armmbed/mbed-os-example-sockets","last_synced_at":"2026-03-04T06:03:10.203Z","repository":{"id":10651898,"uuid":"66503241","full_name":"ARMmbed/mbed-os-example-sockets","owner":"ARMmbed","description":"Simple example for the network-socket API","archived":false,"fork":false,"pushed_at":"2023-02-28T15:20:56.000Z","size":159,"stargazers_count":20,"open_issues_count":0,"forks_count":38,"subscribers_count":98,"default_branch":"development","last_synced_at":"2025-10-30T07:25:23.586Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ARMmbed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-08-24T22:06:43.000Z","updated_at":"2023-10-31T05:53:25.000Z","dependencies_parsed_at":"2025-06-25T20:12:24.163Z","dependency_job_id":"a5a5f10e-a272-4ef1-abf1-94ac5584f9a0","html_url":"https://github.com/ARMmbed/mbed-os-example-sockets","commit_stats":null,"previous_names":[],"tags_count":79,"template":false,"template_full_name":null,"purl":"pkg:github/ARMmbed/mbed-os-example-sockets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMmbed%2Fmbed-os-example-sockets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMmbed%2Fmbed-os-example-sockets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMmbed%2Fmbed-os-example-sockets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMmbed%2Fmbed-os-example-sockets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ARMmbed","download_url":"https://codeload.github.com/ARMmbed/mbed-os-example-sockets/tar.gz/refs/heads/development","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMmbed%2Fmbed-os-example-sockets/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30073690,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T05:31:57.858Z","status":"ssl_error","status_checked_at":"2026-03-04T05:31:38.462Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-25T20:12:18.981Z","updated_at":"2026-03-04T06:03:10.186Z","avatar_url":"https://github.com/ARMmbed.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](./resources/official_armmbed_example_badge.png)\n# Socket Example\n\nThis example shows usage of [network-socket API](https://os.mbed.com/docs/mbed-os/latest/apis/network-socket.html).\n\nThe program brings up an underlying network interface and if it's Wifi also scans for access points.\nIt creates a TCPSocket and performs an HTTP transaction targeting the website in the `mbed_app.json` config.\n\nThe example can be configured to use a TLSSocket. This works only on devices that support TRNG.\n\n## Selecting the network interface\n\nThis application is able to use any network interface it finds.\n\nThe interface selections is done through weak functions that are overridden by your selected target or any additional\ncomponent that provides a network interface.\n\nIf more than one interface is provided the target configuration `target.network-default-interface-type`\nselects the type provided as the default one. This is usually the Ethernet so building on Ethernet enabled boards,\nyou do not need any further configuration.\n\n### Configuring mbedtls\n\nBy default the examples uses a TCP socket. To enable TLS edit the mbed_app.json to turn on the `use-tls-socket` option:\n\n```\n        \"use-tls-socket\": {\n            \"value\": true\n        }\n```\n\nIt might be necessary to configure the mbedtls library with appropriate macros in mbed_app.json file. Some boards\n(like UBLOX_EVK_ODIN_W2) will work fine without any additional configuration and some of them might require some minimal\nadjustment. For example K64F requires at least the following macro added:\n\n\n```\n        \"K64F\": {\n            \"target.macros_add\" : [\"MBEDTLS_SHA1_C\"]\n        }\n```\n\nSee\n[mbedtls configuration guidelines](https://github.com/ARMmbed/mbed-os/tree/master/connectivity/mbedtls#configuring-mbed-tls-features)\nfor more details.\n\nAlso see the API Documentation [TLSSocket](https://os.mbed.com/docs/mbed-os/latest/apis/tlssocket.html).\n\n### WiFi\n\nIf you want to use WiFi you need to provide SSID, password and security settings in `mbed_app.json`.\n\nIf your board doesn't provide WiFi as the default interface because it has multiple interfaces you need to specify that\nyou want WiFi in `mbed_app.json`.\n\n```\n{\n    \"target_overrides\": {\n        \"*\": {\n            \"target.network-default-interface-type\": \"WIFI\",\n        }\n    }\n}\n```\n\nFor more information about Wi-Fi APIs, please visit the\n[Mbed OS Wi-Fi](https://os.mbed.com/docs/mbed-os/latest/apis/wi-fi.html)\ndocumentation.\n\n### Supported WiFi hardware\n\n* All Mbed OS boards with build-in Wi-Fi module such as:\n    * [ST DISCO IOT board](https://os.mbed.com/platforms/ST-Discovery-L475E-IOT01A/) with integrated\n      [ISM43362 WiFi Inventek module](https://github.com/ARMmbed/wifi-ism43362).\n    * [ST DISCO_F413ZH board](https://os.mbed.com/platforms/ST-Discovery-F413H/) with integrated\n      [ISM43362 WiFi Inventek module](https://github.com/ARMmbed/wifi-ism43362).\n* Boards with external WiFi shields such as:\n    * [NUCLEO-F429ZI](https://os.mbed.com/platforms/ST-Nucleo-F429ZI/) with ESP8266-01\n\n## Building and flashing the example\n\n### Mbed OS build tools\n\n#### Mbed CLI 2\n\nStarting with version 6.5, Mbed OS uses Mbed CLI 2. It uses Ninja as a build system, and CMake to generate the build environment and manage the build process in a compiler-independent manner. If you are working with Mbed OS version prior to 6.5 then check the section [Mbed CLI 1](#mbed-cli-1).\n1. [Install Mbed CLI 2](https://os.mbed.com/docs/mbed-os/latest/build-tools/install-or-upgrade.html).\n1. From the command-line, import the example: `mbed-tools import mbed-os-example-sockets`\n1. Change the current directory to where the project was imported.\n\n#### Mbed CLI 1\n1. [Install Mbed CLI 1](https://os.mbed.com/docs/mbed-os/latest/quick-start/offline-with-mbed-cli.html).\n1. From the command-line, import the example: `mbed import mbed-os-example-sockets`\n1. Change the current directory to where the project was imported.\n\n### To build the example\n\n1. Connect a USB cable between the USB port on the board and the host computer.\n1. Run the following command to build the example project and program the microcontroller flash memory:\n\n    * Mbed CLI 2\n\n    ```bash\n    $ mbed-tools compile -m \u003cTARGET\u003e -t \u003cTOOLCHAIN\u003e --flash --sterm\n    ```\n\n    * Mbed CLI 1\n\n    ```bash\n    $ mbed compile -m \u003cTARGET\u003e -t \u003cTOOLCHAIN\u003e --flash --sterm\n    ```\n\nYour PC may take a few minutes to compile your code.\n\nThe binary is located at:\n* **Mbed CLI 2** - `./cmake_build/\u003cTARGET\u003e/\u003cPROFILE\u003e/\u003cTOOLCHAIN\u003e/mbed-os-example-sockets.bin`\u003c/br\u003e\n* **Mbed CLI 1** - `./BUILD/\u003cTARGET\u003e/\u003cTOOLCHAIN\u003e/mbed-os-example-sockets.bin`\n\nAlternatively, you can manually copy the binary to the board, which you mount on the host computer over USB.\n\nYou can also open a serial terminal separately, rather than using the `--sterm` option, with the following command:\n\n* Mbed CLI 2\n\n```bash\n$ mbed-tools sterm\n```\n\n* Mbed CLI 1\n\n```bash\n$ mbed sterm\n```\n\n### Expected output\n\n(Assuming you are using a wifi interface, otherwise the scanning will be skipped)\n\n```\nStarting socket demo\n\n2 networks available:\nNetwork: Virgin Media secured: Unknown BSSID: 2A:35:D1:ba:c7:41 RSSI: -79 Ch: 6\nNetwork: VM4392164 secured: WPA2 BSSID: 18:35:D1:ba:c7:41 RSSI: -79 Ch: 6\n\nConnecting to the network...\nIP address: 192.168.0.27\nNetmask: 255.255.255.0\nGateway: 192.168.0.1\n\nResolve hostname ifconfig.io\nifconfig.io address is 104.24.122.146\n\nsent 52 bytes: \nGET / HTTP/1.1\nHost: ifconfig.io\nConnection: close\n\nreceived 256 bytes:\nHTTP/1.1 200 OK\n\nDemo concluded successfully \n```\n\n## License and contributions\n\nThe software is provided under Apache-2.0 license. Contributions to this project are accepted under the same license.\nPlease see [contributing.md](CONTRIBUTING.md) for more info.\n\nThis project contains code from other projects. The original license text is included in those source files.\nThey must comply with our license guide\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmmbed%2Fmbed-os-example-sockets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farmmbed%2Fmbed-os-example-sockets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmmbed%2Fmbed-os-example-sockets/lists"}