GroupZ - 05012018 1511

Committer:
mslade
Date:
Tue Jan 09 15:01:34 2018 +0000
Revision:
2:15f6847a70ab
Parent:
0:1c898341428b
this version plz;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mslade 0:1c898341428b 1 //#if !FEATURE_LWIP
mslade 0:1c898341428b 2 // #error [NOT_SUPPORTED] LWIP not supported for this target
mslade 0:1c898341428b 3 //#endif
mslade 0:1c898341428b 4 //
mslade 0:1c898341428b 5 //#include "mbed.h"
mslade 0:1c898341428b 6 //#include "EthernetInterface.h"
mslade 0:1c898341428b 7 //#include "TCPServer.h"
mslade 0:1c898341428b 8 //#include "TCPSocket.h"
mslade 0:1c898341428b 9 //
mslade 0:1c898341428b 10 //#define HTTP_STATUS_LINE "HTTP/1.0 200 OK"
mslade 0:1c898341428b 11 //#define HTTP_HEADER_FIELDS "Content-Type: text/html; charset=utf-8"
mslade 0:1c898341428b 12 //#define HTTP_MESSAGE_BODY "" \
mslade 0:1c898341428b 13 //"<html>" "\r\n" \
mslade 0:1c898341428b 14 //" <body style=\"display:flex;text-align:center\">" "\r\n" \
mslade 0:1c898341428b 15 //" <div style=\"margin:auto\">" "\r\n" \
mslade 0:1c898341428b 16 //" <h1>Hello World</h1>" "\r\n" \
mslade 0:1c898341428b 17 //" <p>It works !</p>" "\r\n" \
mslade 0:1c898341428b 18 //" </div>" "\r\n" \
mslade 0:1c898341428b 19 //" </body>" "\r\n" \
mslade 0:1c898341428b 20 //"</html>"
mslade 0:1c898341428b 21 //
mslade 0:1c898341428b 22 //#define HTTP_RESPONSE HTTP_STATUS_LINE "\r\n" \
mslade 0:1c898341428b 23 // HTTP_HEADER_FIELDS "\r\n" \
mslade 0:1c898341428b 24 // "\r\n" \
mslade 0:1c898341428b 25 // HTTP_MESSAGE_BODY "\r\n"
mslade 0:1c898341428b 26 //
mslade 0:1c898341428b 27 //#define IP "10.0.0.10"
mslade 0:1c898341428b 28 //#define NETMASK "255.0.0.0"
mslade 0:1c898341428b 29 //#define GATEWAY "10.0.0.1"
mslade 0:1c898341428b 30 //
mslade 0:1c898341428b 31 //
mslade 0:1c898341428b 32 //int main()
mslade 0:1c898341428b 33 //{
mslade 0:1c898341428b 34 // printf("Basic HTTP server example\n");
mslade 0:1c898341428b 35 //
mslade 0:1c898341428b 36 // //Configure an ethernet connection
mslade 0:1c898341428b 37 // EthernetInterface eth;
mslade 0:1c898341428b 38 // eth.set_network(IP, NETMASK, GATEWAY);
mslade 0:1c898341428b 39 // eth.connect();
mslade 0:1c898341428b 40 // printf("The target IP address is '%s'\n", eth.get_ip_address());
mslade 0:1c898341428b 41 //
mslade 0:1c898341428b 42 // //Now setup a web server
mslade 0:1c898341428b 43 // TCPServer srv; //TCP/IP Server
mslade 0:1c898341428b 44 // TCPSocket clt_sock; //Socket for communication
mslade 0:1c898341428b 45 // SocketAddress clt_addr; //Address of incoming connection
mslade 0:1c898341428b 46 //
mslade 0:1c898341428b 47 // /* Open the server on ethernet stack */
mslade 0:1c898341428b 48 // srv.open(&eth);
mslade 0:1c898341428b 49 //
mslade 0:1c898341428b 50 // /* Bind the HTTP port (TCP 80) to the server */
mslade 0:1c898341428b 51 // srv.bind(eth.get_ip_address(), 80);
mslade 0:1c898341428b 52 //
mslade 0:1c898341428b 53 // /* Can handle 5 simultaneous connections */
mslade 0:1c898341428b 54 // srv.listen(5);
mslade 0:1c898341428b 55 //
mslade 0:1c898341428b 56 // while (true) {
mslade 0:1c898341428b 57 // //Block and wait on an incoming connection
mslade 0:1c898341428b 58 // srv.accept(&clt_sock, &clt_addr);
mslade 0:1c898341428b 59 // printf("accept %s:%d\n", clt_addr.get_ip_address(), clt_addr.get_port());
mslade 0:1c898341428b 60 //
mslade 0:1c898341428b 61 // //Send static HTML response
mslade 0:1c898341428b 62 // clt_sock.send(HTTP_RESPONSE, strlen(HTTP_RESPONSE));
mslade 0:1c898341428b 63 // }
mslade 0:1c898341428b 64 //}