mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
* New section with ESP8266WiFi library documentation * ESP8266WiFi library documentation 1. Introduction - example, diagnostic, doxygen 2. Station - examples, new doc 3. Soft Access Point - examples, new doc 4. Scan - examples, new doc 5. Client - examples, ref. Arduino, setNoDelay, list of functions 6. Client Secure - examples, loadCertificate, setCertificate, list of functions 7. Server- examples, ref. Arduino, setNoDelay, list of functions 8. UDP - examples, ref. Arduino, Multicast UDP 9. Generic - examples, onEvent, WiFiEventHandler, persistent, mode, list of functions * Fixed numbered list
41 lines
2.2 KiB
Markdown
41 lines
2.2 KiB
Markdown
---
|
|
title: ESP8266WiFi UDP Class
|
|
---
|
|
|
|
[ESP8266WiFi Library :back:](readme.md#udp)
|
|
|
|
|
|
## UDP Class
|
|
|
|
Methods documented for [WiFiUDP Class](https://www.arduino.cc/en/Reference/WiFiUDPConstructor) in [Arduino](https://github.com/arduino/Arduino)
|
|
|
|
1. [begin()](https://www.arduino.cc/en/Reference/WiFiUDPBegin)
|
|
2. [available()](https://www.arduino.cc/en/Reference/WiFiUDPAvailable)
|
|
3. [beginPacket()](https://www.arduino.cc/en/Reference/WiFiUDPBeginPacket)
|
|
4. [endPacket()](https://www.arduino.cc/en/Reference/WiFiUDPEndPacket)
|
|
5. [write()](https://www.arduino.cc/en/Reference/WiFiUDPWrite)
|
|
6. [parsePacket()](https://www.arduino.cc/en/Reference/WiFiUDPParsePacket)
|
|
7. [peek()](https://www.arduino.cc/en/Reference/WiFiUDPPeek)
|
|
8. [read()](https://www.arduino.cc/en/Reference/WiFiUDPRead)
|
|
9. [flush()](https://www.arduino.cc/en/Reference/WiFiUDPFlush)
|
|
10. [stop()](https://www.arduino.cc/en/Reference/WiFIUDPStop)
|
|
11. [remoteIP()](https://www.arduino.cc/en/Reference/WiFiUDPRemoteIP)
|
|
12. [remotePort()](https://www.arduino.cc/en/Reference/WiFiUDPRemotePort)
|
|
|
|
|
|
Methods and properties described further down are specific to ESP8266. They are not covered in [Arduino WiFi library](https://www.arduino.cc/en/Reference/WiFi) documentation. Before they are fully documented please refer to information below.
|
|
|
|
|
|
### Multicast UDP
|
|
|
|
```cpp
|
|
uint8_t beginMulticast (IPAddress interfaceAddr, IPAddress multicast, uint16_t port)
|
|
virtual int beginPacketMulticast (IPAddress multicastAddress, uint16_t port, IPAddress interfaceAddress, int ttl=1)
|
|
IPAddress destinationIP ()
|
|
uint16_t localPort ()
|
|
```
|
|
|
|
The `WiFiUDP` class supports sending and receiving multicast packets on STA interface. When sending a multicast packet, replace `udp.beginPacket(addr, port)` with `udp.beginPacketMulticast(addr, port, WiFi.localIP())`. When listening to multicast packets, replace `udp.begin(port)` with `udp.beginMulticast(WiFi.localIP(), multicast_ip_addr, port)`. You can use `udp.destinationIP()` to tell whether the packet received was sent to the multicast or unicast address.
|
|
|
|
|
|
For code samples please refer to separate section with [examples :arrow_right:](udp-examples.md) dedicated specifically to the UDP Class. |