what is the purpose or scenario that remote ip and port should be set again before each calling of espconn_send?

YimingLi

what is the purpose or scenario that remote ip and port should be set again before each calling of espconn_send?

Postby YimingLi » Fri Jun 09, 2017 11:01 am

Hi, Espressif,

[Question]
What is the purpose or scenario that remote ip and remote port should be set again before each calling of espconn_send()? If we use it only for one-to-one repeative UDP communication, is it still a must?

[Description]
The docuement "2c-esp8266-non-os-sdk-api-reference" says in the decription to the function of espconn_send(or espconn_sent) that, "If it is a UDP transmission, please set espconn->proto.udp->remote_ip and remote_port before every calling of espconn_send".

However,

Firstly, we debug by print to find that, if we set the remote_ip and remote_port once during initialization, the remote_ip and remote_port never get changed before each of repeative calling of this function. Even during the time, the sender receive another UDP packet from a third network node to the same local port, the remote_port and remote_ip are still unchanged. Therefore, the set of remote_ip and remote_port seems unnecessary. And our test seems to indicate that there is no failure if we don't set the remote_ip and remote_port each calling of espconn_sent when we do not change the target receiver.

So, what is the actual purpose or scenario of such a must? As you know, if we have to follow this must, we have to assign additional static variable to contain the remote_ip and remote_port, which are actually already in the variable of escconn, which might introduce space consuming or potential logic complexity, especially when we implement multi-link applications.

Secondly, as we know, the UDP is a peer-to-peer network arch(i.e. no server or client actually) so anytime the sender could change the remote_ip and remote_port freely if he expect to change the target receiver and then send. that is, we "could" set remote_ip and remote_port before every calling of espconn_send, but it is not a "must" mandatory.

Be there any mistake or missing , please kindly point them out.

Thanks in advance!

Yiming

Her Mary
Posts: 537
Joined: Mon Oct 27, 2014 11:09 am

Re: what is the purpose or scenario that remote ip and port should be set again before each calling of espconn_send?

Postby Her Mary » Sun Jun 11, 2017 9:00 pm

To be same as socket? In fact, for UDP, it should be sendto.

YimingLi

Re: what is the purpose or scenario that remote ip and port should be set again before each calling of espconn_send?

Postby YimingLi » Tue Jun 13, 2017 1:23 pm

Accoring to my testing experience, espconn_sendto() from SDK older than 2.0.0 has a BIG bug (dollar:p) and not verified it on 2.0.0 or later version(however, it seems that there is no such a bug fix according to the release notes). Therefore, I would rather use espconn_send()/espconn_sent() for UDP as well than use espconn_sendto(). And you may notice that espressif sample code also uses espconn_send() / espconn_sent() for UDP packets other than use espconn_sendto().

Hope it would be useful.

Actually, whether to use espconn_send/espconn_sent or espconn_sendto() makes no difference for the original question of this thread. That is, you would get the same scenario result to the original question.

Then, what is the answer of the original question of this thread ?

Who is online

Users browsing this forum: No registered users and 304 guests