Nathan Yonkee / Mbed OS mbed-os-tcp-server-example
Revision:
4:24963e7cc783
Parent:
3:f4f66901181c
--- a/main.cpp	Tue Aug 08 23:56:11 2017 -0600
+++ b/main.cpp	Wed Aug 09 00:34:03 2017 -0600
@@ -30,7 +30,7 @@
     printf("Basic HTTP server example\n");
 
     EthernetInterface eth;
-    eth.set_network("192.168.1.101", "255.255.255.0","192.168.1.1");
+    /* 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());
@@ -38,8 +38,8 @@
     printf("The target gateway is '%s'\n", eth.get_gateway());
 
     TCPServer srv;
+    TCPSocket clt_sock;
     SocketAddress clt_addr;
-    TCPSocket clt_sock;
 
     /* Open the server on ethernet stack */
     srv.open(&eth);
@@ -49,15 +49,10 @@
 
     /* Can handle 5 simultaneous connections */
     srv.listen(5);
+    while (true) {
     srv.accept(&clt_sock, &clt_addr);
-    while (true) {
-        wait(1);
         printf("accept %s:%d\n", clt_addr.get_ip_address(), clt_addr.get_port());
-        wait(1);
         clt_sock.send(HTTP_RESPONSE, strlen(HTTP_RESPONSE));
-        wait(1);
-        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());
+        /* clt_sock.send("hi\r\n", strlen("hi\r\n")); */
     }
 }