3333#include " Dns.h"
3434
3535/* Constructor */
36- UDP::UDP () : _sock(MAX_SOCK_NUM) {}
36+ EthernetUDP::EthernetUDP () : _sock(MAX_SOCK_NUM) {}
3737
38- /* Start UDP socket, listening at local port PORT */
39- uint8_t UDP ::begin (uint16_t port) {
38+ /* Start EthernetUDP socket, listening at local port PORT */
39+ uint8_t EthernetUDP ::begin (uint16_t port) {
4040 if (_sock != MAX_SOCK_NUM)
4141 return 0 ;
4242
@@ -59,12 +59,12 @@ uint8_t UDP::begin(uint16_t port) {
5959
6060/* Is data available in rx buffer? Returns 0 if no, number of available bytes if yes.
6161 * returned value includes 8 byte UDP header!*/
62- int UDP ::available () {
62+ int EthernetUDP ::available () {
6363 return W5100.getRXReceivedSize (_sock);
6464}
6565
66- /* Release any resources being used by this UDP instance */
67- void UDP ::stop ()
66+ /* Release any resources being used by this EthernetUDP instance */
67+ void EthernetUDP ::stop ()
6868{
6969 if (_sock == MAX_SOCK_NUM)
7070 return ;
@@ -75,7 +75,7 @@ void UDP::stop()
7575 _sock = MAX_SOCK_NUM;
7676}
7777
78- int UDP ::beginPacket (const char *host, uint16_t port)
78+ int EthernetUDP ::beginPacket (const char *host, uint16_t port)
7979{
8080 // Look up the host first
8181 int ret = 0 ;
@@ -91,36 +91,36 @@ int UDP::beginPacket(const char *host, uint16_t port)
9191 }
9292}
9393
94- int UDP ::beginPacket (IPAddress ip, uint16_t port)
94+ int EthernetUDP ::beginPacket (IPAddress ip, uint16_t port)
9595{
9696 _offset = 0 ;
97- return startUDP (_sock, ip. raw_address ( ), port);
97+ return startUDP (_sock, rawIPAddress (ip ), port);
9898}
9999
100- int UDP ::endPacket ()
100+ int EthernetUDP ::endPacket ()
101101{
102102 return sendUDP (_sock);
103103}
104104
105- size_t UDP ::write (uint8_t byte)
105+ size_t EthernetUDP ::write (uint8_t byte)
106106{
107107 return write (&byte, 1 );
108108}
109109
110- size_t UDP ::write (const char *str)
110+ size_t EthernetUDP ::write (const char *str)
111111{
112112 size_t len = strlen (str);
113113 return write ((const uint8_t *)str, len);
114114}
115115
116- size_t UDP ::write (const uint8_t *buffer, size_t size)
116+ size_t EthernetUDP ::write (const uint8_t *buffer, size_t size)
117117{
118118 uint16_t bytes_written = bufferData (_sock, _offset, buffer, size);
119119 _offset += bytes_written;
120120 return bytes_written;
121121}
122122
123- int UDP ::parsePacket ()
123+ int EthernetUDP ::parsePacket ()
124124{
125125 if (available () > 0 )
126126 {
@@ -143,7 +143,7 @@ int UDP::parsePacket()
143143 return 0 ;
144144}
145145
146- int UDP ::read ()
146+ int EthernetUDP ::read ()
147147{
148148 uint8_t byte;
149149 if (recv (_sock, &byte, 1 ) > 0 )
@@ -155,7 +155,7 @@ int UDP::read()
155155 return -1 ;
156156}
157157
158- int UDP ::read (unsigned char * buffer, size_t len)
158+ int EthernetUDP ::read (unsigned char * buffer, size_t len)
159159{
160160 /* In the readPacket that copes with truncating packets, the buffer was
161161 filled with this code. Not sure why it loops round reading out a byte
@@ -169,7 +169,7 @@ int UDP::read(unsigned char* buffer, size_t len)
169169 return recv (_sock, buffer, len);
170170}
171171
172- int UDP ::peek ()
172+ int EthernetUDP ::peek ()
173173{
174174 uint8_t b;
175175 // Unlike recv, peek doesn't check to see if there's any data available, so we must
@@ -179,7 +179,7 @@ int UDP::peek()
179179 return b;
180180}
181181
182- void UDP ::flush ()
182+ void EthernetUDP ::flush ()
183183{
184184 while (available ())
185185 {
0 commit comments