Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncUDP创建客户端连接ipv6地址前必须要listen固定端口,WiFiUDP也一样要先begin固定端口 #10924

Closed
1 task done
cers000 opened this issue Jan 31, 2025 · 2 comments
Labels
Status: Awaiting triage Issue is waiting for triage

Comments

@cers000
Copy link

cers000 commented Jan 31, 2025

Board

ESP32-C3 Dev Board

Device Description

合宙ESP32C3-CORE开发板

Hardware Configuration

Type-C 连接到电脑USB接口,其他没有连接设备

Version

latest master (checkout manually)

IDE Name

arduino ide

Operating System

Win10

Flash frequency

40Mhz

PSRAM enabled

yes

Upload speed

9612000

Description

使用AsyncUDP作为客户端连接服务器时总是需要使用listen绑定端口,如果不绑定指定端口,就无法在ipv6协议栈发送数据,提示
/** Illegal value. */
ERR_VAL = -6,

使用WiFiUDP(或者NetworkUDP)作为客户端连接服务器时总是需要使用begin绑定端口,如果不绑定指定端口,就无法在ipv6协议栈发送数据,提示
#define EINVAL 22 /* Invalid argument */

当然,在ipv4环境下不会有任何错误提示,也能正常发送数据,似乎是ipv6的协议栈没有做判别处理导致调用了ipv4的接口来发送ipv6的数据导致参数错误。

Sketch

//AsyncUDP
IPAddress localAddress("::");
const uint16_t localUdpPort = 2333;

IPAddress sAddress("240e:368:FFFF:FFEE:6255:f9ff:fe72:d914");
const uint16_t sPort = 2333;

udp.listen(localAddress, localUdpPort);//如果不使用这一句来绑定ipv6地址和端口就会报错
udp.onPacket(onPacketCallBack);  //注册收到数据包事件

udp.connect(sAddress, sPort);
AsyncUDPMessage aUdpMsg(100);
aUdpMsg.write('c');
Serial.println(aUdpMsg.length());
int si = udp.send(aUdpMsg);
Serial.println(si);
Serial.println(udp.lastErr());


//WiFiUDP or NetworkUDP
udp.begin(localAddress, localUdpPort );//如果不使用这一句来绑定ipv6地址和端口就会报错
udp.beginPacket(sAddress, sPort);
udp.print("d");
udp.endPacket();

Debug Message

/** Illegal value.           */
  ERR_VAL        = -6,


#define  EINVAL          22  /* Invalid argument */

Other Steps to Reproduce

我仔细比较了一下connect和listen的实现,发现确实connect没有对ipv6做针对性处理
begin和beginPacket也一样,beginPacket没有对ipv6做针对性处理
Image
Image

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@cers000 cers000 added the Status: Awaiting triage Issue is waiting for triage label Jan 31, 2025
@me-no-dev
Copy link
Member

Please use English and open a new issue

@cers000
Copy link
Author

cers000 commented Feb 1, 2025

你可以使用翻译软件翻译我的描述,谁告诉你这是英文区的?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

No branches or pull requests

2 participants