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.
Diff: main.cpp
- Revision:
- 3:f4f66901181c
- Parent:
- 1:59e0d83a4014
- Child:
- 4:24963e7cc783
--- a/main.cpp Wed Aug 09 05:12:41 2017 +0000 +++ b/main.cpp Tue Aug 08 23:56:11 2017 -0600 @@ -1,5 +1,5 @@ #if !FEATURE_LWIP - #error [NOT_SUPPORTED] LWIP not supported for this target +#error [NOT_SUPPORTED] LWIP not supported for this target #endif #include "mbed.h" @@ -26,25 +26,27 @@ DigitalIn swtch(PD_14); -int main() -{ +int main() { printf("Basic HTTP server example\n"); - + EthernetInterface eth; + eth.set_network("192.168.1.101", "255.255.255.0","192.168.1.1"); eth.connect(); - + printf("The target IP address is '%s'\n", eth.get_ip_address()); - + printf("The target netmask is '%s'\n", eth.get_netmask()); + printf("The target gateway is '%s'\n", eth.get_gateway()); + TCPServer srv; SocketAddress clt_addr; TCPSocket clt_sock; - + /* Open the server on ethernet stack */ srv.open(ð); - + /* Bind the HTTP port (TCP 80) to the server */ srv.bind(eth.get_ip_address(), 80); - + /* Can handle 5 simultaneous connections */ srv.listen(5); srv.accept(&clt_sock, &clt_addr); @@ -54,7 +56,7 @@ wait(1); clt_sock.send(HTTP_RESPONSE, strlen(HTTP_RESPONSE)); wait(1); -clt_sock.send("hi\r\n", strlen("hi\r\n")); + clt_sock.send("hi\r\n", strlen("hi\r\n")); if( swtch == 0 ) clt_sock.send("hi\r\n", strlen("hi\r\n")); printf("accept %s:%d\n", clt_addr.get_ip_address(), clt_addr.get_port()); }