The code from https://github.com/vpcola/Nucleo

Committer:
sinrab
Date:
Wed Oct 08 11:00:24 2014 +0000
Revision:
0:5464d5e415e5
The code from https://github.com/vpcola/Nucleo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sinrab 0:5464d5e415e5 1 /* Copyright (C) 2013 mbed.org, MIT License
sinrab 0:5464d5e415e5 2 *
sinrab 0:5464d5e415e5 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
sinrab 0:5464d5e415e5 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
sinrab 0:5464d5e415e5 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
sinrab 0:5464d5e415e5 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
sinrab 0:5464d5e415e5 7 * furnished to do so, subject to the following conditions:
sinrab 0:5464d5e415e5 8 *
sinrab 0:5464d5e415e5 9 * The above copyright notice and this permission notice shall be included in all copies or
sinrab 0:5464d5e415e5 10 * substantial portions of the Software.
sinrab 0:5464d5e415e5 11 *
sinrab 0:5464d5e415e5 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
sinrab 0:5464d5e415e5 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
sinrab 0:5464d5e415e5 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
sinrab 0:5464d5e415e5 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
sinrab 0:5464d5e415e5 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
sinrab 0:5464d5e415e5 17 */
sinrab 0:5464d5e415e5 18
sinrab 0:5464d5e415e5 19 #ifndef UDPSOCKET_H
sinrab 0:5464d5e415e5 20 #define UDPSOCKET_H
sinrab 0:5464d5e415e5 21
sinrab 0:5464d5e415e5 22 #include "Endpoint.h"
sinrab 0:5464d5e415e5 23 #include "Socket.h"
sinrab 0:5464d5e415e5 24
sinrab 0:5464d5e415e5 25 #include <cstdint>
sinrab 0:5464d5e415e5 26
sinrab 0:5464d5e415e5 27 /**
sinrab 0:5464d5e415e5 28 UDP Socket
sinrab 0:5464d5e415e5 29 */
sinrab 0:5464d5e415e5 30 class UDPSocket: public Socket {
sinrab 0:5464d5e415e5 31
sinrab 0:5464d5e415e5 32 public:
sinrab 0:5464d5e415e5 33 /** Instantiate an UDP Socket.
sinrab 0:5464d5e415e5 34 */
sinrab 0:5464d5e415e5 35 UDPSocket();
sinrab 0:5464d5e415e5 36
sinrab 0:5464d5e415e5 37 /** Init the UDP Client Socket without binding it to any specific port
sinrab 0:5464d5e415e5 38 \return 0 on success, -1 on failure.
sinrab 0:5464d5e415e5 39 */
sinrab 0:5464d5e415e5 40 int init(void);
sinrab 0:5464d5e415e5 41
sinrab 0:5464d5e415e5 42 /** Bind a UDP Server Socket to a specific port
sinrab 0:5464d5e415e5 43 \param port The port to listen for incoming connections on
sinrab 0:5464d5e415e5 44 \return 0 on success, -1 on failure.
sinrab 0:5464d5e415e5 45 */
sinrab 0:5464d5e415e5 46 int bind(int port = -1);
sinrab 0:5464d5e415e5 47
sinrab 0:5464d5e415e5 48 /** Send a packet to a remote endpoint
sinrab 0:5464d5e415e5 49 \param remote The remote endpoint
sinrab 0:5464d5e415e5 50 \param packet The packet to be sent
sinrab 0:5464d5e415e5 51 \param length The length of the packet to be sent
sinrab 0:5464d5e415e5 52 \return the number of written bytes on success (>=0) or -1 on failure
sinrab 0:5464d5e415e5 53 */
sinrab 0:5464d5e415e5 54 int sendTo(Endpoint &remote, char *packet, int length);
sinrab 0:5464d5e415e5 55
sinrab 0:5464d5e415e5 56 /** Receive a packet from a remote endpoint
sinrab 0:5464d5e415e5 57 \param remote The remote endpoint
sinrab 0:5464d5e415e5 58 \param buffer The buffer for storing the incoming packet data. If a packet
sinrab 0:5464d5e415e5 59 is too long to fit in the supplied buffer, excess bytes are discarded
sinrab 0:5464d5e415e5 60 \param length The length of the buffer
sinrab 0:5464d5e415e5 61 \return the number of received bytes on success (>=0) or -1 on failure
sinrab 0:5464d5e415e5 62 */
sinrab 0:5464d5e415e5 63 int receiveFrom(Endpoint &remote, char *buffer, int length);
sinrab 0:5464d5e415e5 64 };
sinrab 0:5464d5e415e5 65
sinrab 0:5464d5e415e5 66 #include "def.h"
sinrab 0:5464d5e415e5 67
sinrab 0:5464d5e415e5 68 #endif
sinrab 0:5464d5e415e5 69