
A small example of TCP server over ethernet for mbed-os.
Revision 1:ec61ea9f67de, committed 2016-11-14
- Comitter:
- adustm
- Date:
- Mon Nov 14 15:34:13 2016 +0000
- Parent:
- 0:6e8275981824
- Child:
- 2:e72bc303ea90
- Commit message:
- change feature IPV4 to LWIP + srv.accept command modification
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Sep 22 11:20:29 2016 +0000 +++ b/main.cpp Mon Nov 14 15:34:13 2016 +0000 @@ -1,5 +1,5 @@ -#if !FEATURE_IPV4 - #error [NOT_SUPPORTED] IPV4 not supported for this target +#if !FEATURE_LWIP + #error [NOT_SUPPORTED] LWIP not supported for this target #endif #include "mbed.h" @@ -35,7 +35,7 @@ TCPServer srv; TCPSocket clt_sock; - //SocketAddress clt_addr; + SocketAddress clt_addr; /* Open the server on ethernet stack */ srv.open(ð); @@ -47,11 +47,8 @@ srv.listen(5); while (true) { - // Will be possible in releaseb 126 - //srv.accept(&clt_sock, &clt_addr); - //printf("accept %s:%d\n", clt_addr.get_ip_address(), clt_addr.get_port()); - srv.accept(&clt_sock); - printf("new client accepted\n"); + srv.accept(&clt_sock, &clt_addr); + printf("accept %s:%d\n", clt_addr.get_ip_address(), clt_addr.get_port()); clt_sock.send(HTTP_RESPONSE, strlen(HTTP_RESPONSE)); } }
--- a/mbed-os.lib Thu Sep 22 11:20:29 2016 +0000 +++ b/mbed-os.lib Mon Nov 14 15:34:13 2016 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#21dd7008a1540c02150f1b87c12294301db979bb +https://github.com/ARMmbed/mbed-os/#a1c0840b3d69060e5eb708edb18358e424a40f51