• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

main/11-Mar-2024-166118

CMakeLists.txtD11-Mar-2024464 118

MakefileD11-Mar-2024269 113

README.mdD11-Mar-20242.5 KiB7748

example_test.pyD11-Mar-20243.6 KiB10677

sdkconfig.ciD11-Mar-202444 32

README.md

1
2# UDP Server example
3
4(See the README.md file in the upper level 'examples' directory for more information about examples.)
5
6The application creates UDP socket with the specified port number and waits for the data to be received. Received data are printed as ASCII text and retransmitted back to the client.
7
8## How to use example
9
10In order to create UDP client that communicates with UDP server example, choose one of the following options.
11
12There are many host-side tools which can be used to interact with the UDP/TCP server/client.
13One command line tool is [netcat](http://netcat.sourceforge.net) which can send and receive many kinds of packets.
14Note: please replace `192.168.0.167 3333` with desired IPV4/IPV6 address (displayed in monitor console) and port number in the following commands.
15
16In addition to those tools, simple Python scripts can be found under sockets/scripts directory. Every script is designed to interact with one of the examples.
17
18### Send UDP packet via netcat
19```
20echo "Hello from PC" | nc -w1 -u 192.168.0.167 3333
21```
22
23### Receive UDP packet via netcat
24```
25echo "Hello from PC" | nc -w1 -u 192.168.0.167 3333
26```
27
28### UDP client using netcat
29```
30nc -u 192.168.0.167 3333
31```
32
33### Python scripts
34Script example_test.py could be used as a counter part to the udp-server application,
35IP address and the message to be send to the server shall be stated as arguments. Example:
36
37```
38python example_test.py 192.168.0.167 Message
39```
40Note that this script is used in automated tests, as well, so the IDF test framework packages need to be imported;
41please add `$IDF_PATH/tools/ci/python_packages` to `PYTHONPATH`.
42
43## Hardware Required
44
45This example can be run on any commonly available ESP32 development board.
46
47## Configure the project
48
49```
50idf.py menuconfig
51```
52
53Set following parameters under Example Configuration Options:
54
55* Set `IP version` of the example to be IPV4 or IPV6.
56
57* Set `Port` number that represents remote port the example will create.
58
59Configure Wi-Fi or Ethernet under "Example Connection Configuration" menu. See "Establishing Wi-Fi or Ethernet Connection" section in [examples/protocols/README.md](../../README.md) for more details.
60
61## Build and Flash
62
63Build the project and flash it to the board, then run monitor tool to view serial output:
64
65```
66idf.py -p PORT flash monitor
67```
68
69(To exit the serial monitor, type ``Ctrl-]``.)
70
71See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
72
73
74## Troubleshooting
75
76Start server first, to receive data sent from the client (application).
77