Ethernet test for ECE 4180 and others to find your IP address and do a simple HTTP GET request over port 80.
Dependencies: mbed Socket lwip-eth lwip-sys lwip
EthernetInterface/Socket/TCPSocketServer.h@0:e7ca326e76ee, 2013-04-04 (annotated)
- Committer:
- mkersh3
- Date:
- Thu Apr 04 05:26:09 2013 +0000
- Revision:
- 0:e7ca326e76ee
Ethernet Test for ECE4180 and others to find their IP Address and do a simple HTTP GET request over port 80.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mkersh3 | 0:e7ca326e76ee | 1 | /* Copyright (C) 2012 mbed.org, MIT License |
mkersh3 | 0:e7ca326e76ee | 2 | * |
mkersh3 | 0:e7ca326e76ee | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
mkersh3 | 0:e7ca326e76ee | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
mkersh3 | 0:e7ca326e76ee | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
mkersh3 | 0:e7ca326e76ee | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
mkersh3 | 0:e7ca326e76ee | 7 | * furnished to do so, subject to the following conditions: |
mkersh3 | 0:e7ca326e76ee | 8 | * |
mkersh3 | 0:e7ca326e76ee | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
mkersh3 | 0:e7ca326e76ee | 10 | * substantial portions of the Software. |
mkersh3 | 0:e7ca326e76ee | 11 | * |
mkersh3 | 0:e7ca326e76ee | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
mkersh3 | 0:e7ca326e76ee | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
mkersh3 | 0:e7ca326e76ee | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
mkersh3 | 0:e7ca326e76ee | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
mkersh3 | 0:e7ca326e76ee | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
mkersh3 | 0:e7ca326e76ee | 17 | */ |
mkersh3 | 0:e7ca326e76ee | 18 | #ifndef TCPSOCKETSERVER_H |
mkersh3 | 0:e7ca326e76ee | 19 | #define TCPSOCKETSERVER_H |
mkersh3 | 0:e7ca326e76ee | 20 | |
mkersh3 | 0:e7ca326e76ee | 21 | #include "Socket/Socket.h" |
mkersh3 | 0:e7ca326e76ee | 22 | #include "TCPSocketConnection.h" |
mkersh3 | 0:e7ca326e76ee | 23 | |
mkersh3 | 0:e7ca326e76ee | 24 | /** TCP Server. |
mkersh3 | 0:e7ca326e76ee | 25 | */ |
mkersh3 | 0:e7ca326e76ee | 26 | class TCPSocketServer : public Socket { |
mkersh3 | 0:e7ca326e76ee | 27 | public: |
mkersh3 | 0:e7ca326e76ee | 28 | /** Instantiate a TCP Server. |
mkersh3 | 0:e7ca326e76ee | 29 | */ |
mkersh3 | 0:e7ca326e76ee | 30 | TCPSocketServer(); |
mkersh3 | 0:e7ca326e76ee | 31 | |
mkersh3 | 0:e7ca326e76ee | 32 | /** Bind a socket to a specific port. |
mkersh3 | 0:e7ca326e76ee | 33 | \param port The port to listen for incoming connections on. |
mkersh3 | 0:e7ca326e76ee | 34 | \return 0 on success, -1 on failure. |
mkersh3 | 0:e7ca326e76ee | 35 | */ |
mkersh3 | 0:e7ca326e76ee | 36 | int bind(int port); |
mkersh3 | 0:e7ca326e76ee | 37 | |
mkersh3 | 0:e7ca326e76ee | 38 | /** Start listening for incoming connections. |
mkersh3 | 0:e7ca326e76ee | 39 | \param backlog number of pending connections that can be queued up at any |
mkersh3 | 0:e7ca326e76ee | 40 | one time [Default: 1]. |
mkersh3 | 0:e7ca326e76ee | 41 | \return 0 on success, -1 on failure. |
mkersh3 | 0:e7ca326e76ee | 42 | */ |
mkersh3 | 0:e7ca326e76ee | 43 | int listen(int backlog=1); |
mkersh3 | 0:e7ca326e76ee | 44 | |
mkersh3 | 0:e7ca326e76ee | 45 | /** Accept a new connection. |
mkersh3 | 0:e7ca326e76ee | 46 | \param connection A TCPSocketConnection instance that will handle the incoming connection. |
mkersh3 | 0:e7ca326e76ee | 47 | \return 0 on success, -1 on failure. |
mkersh3 | 0:e7ca326e76ee | 48 | */ |
mkersh3 | 0:e7ca326e76ee | 49 | int accept(TCPSocketConnection& connection); |
mkersh3 | 0:e7ca326e76ee | 50 | }; |
mkersh3 | 0:e7ca326e76ee | 51 | |
mkersh3 | 0:e7ca326e76ee | 52 | #endif |