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

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?

UserRevisionLine numberNew 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
mkersh3 0:e7ca326e76ee 19 #ifndef UDPSOCKET_H
mkersh3 0:e7ca326e76ee 20 #define UDPSOCKET_H
mkersh3 0:e7ca326e76ee 21
mkersh3 0:e7ca326e76ee 22 #include "Socket/Socket.h"
mkersh3 0:e7ca326e76ee 23 #include "Socket/Endpoint.h"
mkersh3 0:e7ca326e76ee 24
mkersh3 0:e7ca326e76ee 25 #include <cstdint>
mkersh3 0:e7ca326e76ee 26
mkersh3 0:e7ca326e76ee 27 /**
mkersh3 0:e7ca326e76ee 28 UDP Socket
mkersh3 0:e7ca326e76ee 29 */
mkersh3 0:e7ca326e76ee 30 class UDPSocket : public Socket {
mkersh3 0:e7ca326e76ee 31
mkersh3 0:e7ca326e76ee 32 public:
mkersh3 0:e7ca326e76ee 33 /** Instantiate an UDP Socket.
mkersh3 0:e7ca326e76ee 34 */
mkersh3 0:e7ca326e76ee 35 UDPSocket();
mkersh3 0:e7ca326e76ee 36
mkersh3 0:e7ca326e76ee 37 /** Init the UDP Client Socket without binding it to any specific port
mkersh3 0:e7ca326e76ee 38 \return 0 on success, -1 on failure.
mkersh3 0:e7ca326e76ee 39 */
mkersh3 0:e7ca326e76ee 40 int init(void);
mkersh3 0:e7ca326e76ee 41
mkersh3 0:e7ca326e76ee 42 /** Bind a UDP Server Socket to a specific port
mkersh3 0:e7ca326e76ee 43 \param port The port to listen for incoming connections on
mkersh3 0:e7ca326e76ee 44 \return 0 on success, -1 on failure.
mkersh3 0:e7ca326e76ee 45 */
mkersh3 0:e7ca326e76ee 46 int bind(int port);
mkersh3 0:e7ca326e76ee 47
mkersh3 0:e7ca326e76ee 48 /** Send a packet to a remote endpoint
mkersh3 0:e7ca326e76ee 49 \param remote The remote endpoint
mkersh3 0:e7ca326e76ee 50 \param packet The packet to be sent
mkersh3 0:e7ca326e76ee 51 \param length The length of the packet to be sent
mkersh3 0:e7ca326e76ee 52 \return the number of written bytes on success (>=0) or -1 on failure
mkersh3 0:e7ca326e76ee 53 */
mkersh3 0:e7ca326e76ee 54 int sendTo(Endpoint &remote, char *packet, int length);
mkersh3 0:e7ca326e76ee 55
mkersh3 0:e7ca326e76ee 56 /** Receive a packet from a remote endpoint
mkersh3 0:e7ca326e76ee 57 \param remote The remote endpoint
mkersh3 0:e7ca326e76ee 58 \param buffer The buffer for storing the incoming packet data. If a packet
mkersh3 0:e7ca326e76ee 59 is too long to fit in the supplied buffer, excess bytes are discarded
mkersh3 0:e7ca326e76ee 60 \param length The length of the buffer
mkersh3 0:e7ca326e76ee 61 \return the number of received bytes on success (>=0) or -1 on failure
mkersh3 0:e7ca326e76ee 62 */
mkersh3 0:e7ca326e76ee 63 int receiveFrom(Endpoint &remote, char *buffer, int length);
mkersh3 0:e7ca326e76ee 64 };
mkersh3 0:e7ca326e76ee 65
mkersh3 0:e7ca326e76ee 66 #endif