This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088
Fork of libMiMic by
Diff: mbed/UdpSocket.h
- Revision:
- 58:03b89038b21a
- Child:
- 60:803de2088243
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed/UdpSocket.h Fri Sep 27 12:47:51 2013 +0000 @@ -0,0 +1,50 @@ +#pragma once +//////////////////////////////////////////////////////////////////////////////// +// UdpSocket.h +//////////////////////////////////////////////////////////////////////////////// + +#include "NyLPC_net.h" +#include "IpAddr.h" + +namespace MiMic +{ + /** + * Udp Socket Class. + * The class is used by Net constructor. + */ + class UdpSocket + { + private: + NyLPC_TcUdpSocket_t _inst; + void* _private_rx; + public: + /** wrapped base LPC class.*/ + NyLPC_TcUdpSocket_t* refBaseInstance(){return &this->_inst;} + + public: + UdpSocket(unsigned short i_port,unsigned short i_rx_buf_size=(unsigned short)512); + UdpSocket(unsigned short i_port,void* i_rx_buf,unsigned short i_rx_buf_size); + /** + * This constructor accepts "large" packet by asynchronous handler. + * Must be override "onRxHandler" function. + */ + UdpSocket(unsigned short i_port,void* i_rx_handler); + virtual ~UdpSocket(); + /** + * This function return recieved data and size. + * The function sets the head of the oldest readable buffer. + * A position is not changed until precvnext was called. + * @param i_host_addr + * must be IPv4 address format. + */ + int precvfrom(const void* &i_rx,IpAddr* i_peer_host=NULL,unsigned short* i_port=NULL); + /** + * This function moves rx buffer to next packet. + */ + void precvnext(void); + bool sendTo(const IpAddr& i_host,unsigned short i_port,const void* i_tx,unsigned short i_tx_size); + void joinMulticast(const IpAddr& i_host); + void setBroadcast(void); + }; +} +