GitHub hosted

Download repository: zip

Getting started with the network-socket API

This is a quick example of a simple HTTP client program using the
network-socket API that Mbed OS provides.

The program brings up an underlying network interface, and uses it to perform an HTTP
transaction over a TCPSocket.

Note: The current example is limited to the ethernet interface on supported devices.
To use the example with a different interface, you will need to modify main.cpp and
replace the EthernetInterface class with the appropriate interface.


mbed compile -t <toolchain> -m <target>

For example, building for K64F using GCC: mbed compile -t GCC_ARM -m K64F

Expected output

Note: The default serial port baud rate is 9600 bit/s.

IP address:
sent 39 [GET / HTTP/1.1]
recv 173 [HTTP/1.1 200 OK]
External IP address:


More information on the network-socket API can be found in the mbed handbook.


If you have problems, you can review the documentation for suggestions on what could be wrong and how to fix it.