-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
UDP Server won't respond to client #1074
Comments
It can't be considered "reported" unless there's an issue here on GitHub for this. Also, why do you consider the "solution" described in the blog post by @reischle not applicable for you? After all, default |
This code works for me with the latest dev build. There is a more interesting question as to whether it ought to work! In order for the s:send to send the packet back to the originator, the socket must have that destination address attached to it. The question is when does this happen (and it doesn't appear to be in the lua interface code, so it must be in the lwip stack or (more likely) the esp sdk). if you run
and do two However, running under a stress test with this code
showed that (at least for me) that the s:send from the receive callback always went to the address that the original packet came from. |
@marcelstoer Yea, I didn't mean reported as in a ticket was filed... just that someone had seen something like this in the past. I don't consider it the same problem as what I'm having though because the firmware version I'm using already has the change he suggests. @pjsg That is interesting! I'll flash with the new firmware as soon as possible. |
Just curious... shouldn't the s:listen(blah) call be done after the s:on("receive") setting for UDP servers? I saw that somewhere and found it curious, but here it's listen() and then on() (the other way around). Or does the order not really matter? |
Yup, the documentation is wrong BTW. In the case of UDP the function argument to the listen command is ignored since a UDP session is connectionless. The tmr.alarm(1,5000,0,function()
print("IP:", wifi.sta.getip())
s=net.createServer(net.UDP)
local on,send,n=s.on,s.send,0
s:listen(5683)
on(s,"receive", function (sk,r)
n = n%4 + 1
tmr.alarm(n,5000,0,
function() send(sk,"echo:"..r..tostring(sk)) end)
end)
end)
It doesn't make a damn bit of difference so long as they are done in the same task. |
I took a look at the net code hoping to be able to add a getpeer call on a udp server socket, but it appears (to me) as though the espconn layer hides this information. I could add a new api to get this data, but that seems nasty,,,,, |
Phil, I am going through the net module, so the is little point in us both doing this unless we work together. I'd be interested in you comments on this latest GPIO low trigger issue though -- #1078 |
I think that we've explained this issue, and addressing it will be a matter for #1080 anyway. |
Hey... I'm having a strange problem.
I'm trying to run a sample of the fragment code which starts a UDP echo server but the response never goes through,
The board is fine and doesn't throw an error but my client (
echo 'hello' | nc -u <ip> 5683
) never sees the reply. This problem seems to have been reported in the past, but their solution doesn't seem applicable.Any ideas?
The text was updated successfully, but these errors were encountered: