Fork of original library, increased Tx buffer to 16kB

Dependents:   W5500-SNTPClient-example

Committer:
star297
Date:
Thu May 02 20:47:25 2019 +0000
Revision:
0:e9275bdfa393
First commit

Who changed what in which revision?

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