SNICInterface for ThingPlug Example

Dependents:   ThingPlug_WiFi_Example ThingPlug_WiFi_Example_2

Fork of SNICInterface by muRata

Committer:
kishino
Date:
Wed Mar 26 04:38:12 2014 +0000
Revision:
14:54378c96d285
Parent:
4:99cc93fe7d88
Added a comment of copyright.

Who changed what in which revision?

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