WIFI_API_20150524e

Committer:
Marcomissyou
Date:
Tue Jun 09 06:04:13 2015 +0000
Revision:
0:a2de37bf5f3d
update to WIFI_API_20150524e

Who changed what in which revision?

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