Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of net-test by
Diff: main.cpp
- Revision:
- 0:dcf432232b87
- Child:
- 1:e01aa8a340ad
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Oct 13 22:05:24 2016 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" +#include "EthernetInterface.h" +#include "chlibs.h" + +#define PEER "10.212.1.246" + +EthernetInterface eth; + +static void try_connect(unsigned port) { + INFO("connect %s:%u", PEER, port); + TCPSocket sock; + int err = sock.open(ð); + if (err < 0) { + ch_report("sock.open", err); + return; + } + err = sock.connect(PEER, port); + if (err < 0) { + ch_report("sock.connect", err); + return; + } +} + +int main() { + ch_log_level = CH_LOG_INFO; + INFO("net-test %s %s", __DATE__, __TIME__); + + int err = eth.connect(); + if (err < 0) ch_fail("eth.connect", err); + INFO("IP address %s", eth.get_ip_address()); + + try_connect(7); + + INFO("End"); + return 0; +} \ No newline at end of file