Skip to content

[ch1668] UDP socket validity check #766

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

Closed
wants to merge 4 commits into from
Closed

[ch1668] UDP socket validity check #766

wants to merge 4 commits into from

Conversation

aledand
Copy link

@aledand aledand commented Dec 14, 2015

sockets become invalid after a WiFi reconnect. this should let user code to check it.

@m-mcgowan
Copy link
Contributor

This is great. Would you mind adding docs and tests to support this change? Details are in our contributions doc - https://github.com/spark/firmware/blob/develop/CONTRIBUTING.md. Thanks!

@aledand
Copy link
Author

aledand commented Dec 14, 2015

So far not so much time for the full chain, I'll do my best.

@m-mcgowan
Copy link
Contributor

Any objections to merging this?

In our discussions on logging today, calling read/write and other operations on TCP/UDP objects that are not valid is a good example of where we'd emit a WARN or ERROR log.

@m-mcgowan m-mcgowan added this to the 0.6.x milestone Apr 23, 2016
@aledand
Copy link
Author

aledand commented Apr 23, 2016

no of course no objections

@m-mcgowan m-mcgowan self-assigned this Apr 26, 2016
@m-mcgowan m-mcgowan removed this from the 0.6.x milestone Apr 27, 2016
@m-mcgowan
Copy link
Contributor

m-mcgowan commented Apr 27, 2016

@aledand - would you please sign our CLA - https://docs.google.com/a/particle.io/forms/d/1_2P-vRKGUFg5bmpcKLHO_qNZWGi5HKYnfrrkd-sbZoA/viewform.

For consistency, we should add an isValid() also to the TCPClient object (and TCPServer). I can add that if you don't have time for it.

@aledand
Copy link
Author

aledand commented Apr 28, 2016

done

Il giorno mer 27 apr 2016 alle ore 23:21 Matthew [email protected]
ha scritto:

@aledand https://github.com/aledand - would you please sign our CLA -
https://docs.google.com/a/particle.io/forms/d/1_2P-vRKGUFg5bmpcKLHO_qNZWGi5HKYnfrrkd-sbZoA/viewform
.

For consistency, we need to add an isValid() also to the TCPClient object
(and TCPServer) and provide a simple API that tries to automatically
reconnect disconnected networking instances (as described in #982
https://github.com/spark/firmware/issues/982) plus a system event when
network interfaces come and go so more advanced applications can interact
with that and introduce their own handling.


You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub
#766 (comment)

@technobly technobly changed the title UDP sockect validity check UDP socket validity check Dec 12, 2016
@technobly
Copy link
Member

Closing until tests can be added for this. Added to Clubhouse 1667.

@technobly technobly closed this Dec 12, 2016
@technobly technobly changed the title UDP socket validity check UDP socket validity check [ch1668] Jan 17, 2017
@technobly technobly changed the title UDP socket validity check [ch1668] [ch1668] UDP socket validity check Jan 17, 2017
@technobly
Copy link
Member

technobly commented Feb 9, 2017

We currently have TCPClient::status() that acts this way, validating the TCP socket, although it needs to be documented (particle-iot/docs#569). Perhaps this PR should rename the API to UDP::status() and && it with .ready() like TCP does and use the isOpen(_sock) function instead of duplicating that code.

For reference, TCPClient::status() is

uint8_t TCPClient::status()
{
  return (isOpen(_sock) && Network.from(nif).ready() && (SOCKET_STATUS_ACTIVE == socket_active_status(_sock)));
}

So proposed UDP::status() would be

uint8_t UDP::status()
{
  return ( isOpen(_sock) && Network.from(nif).ready() );
}

Unclear if socket_active_status(_sock) can be used with UDP... need to research.


This would address issue #1243

@Pixinger
Copy link

Hi, sorry for posting in a closed topic.
But as this topic is closed and me having the same issue with UDP validation, I just wantet to ask what the current state of this problem is. Does CLOSE mean "it will not be done", "already done" or "out of men power"?
I help myself with regularly checking WiFi.ready(), but as Barakwei in this issue #1243 pointed out, this is not a good solution.
Please don't feel offended, I just did not know a better palce to ask.
Best regards, Pix

@stewartadam
Copy link

What's the current status of this? This is closed, but the PR for documenting these calls is open and it seems neither Udp.status() nor Udp.isValid() are present in the 0.7.0 release despite these PRs dating years ago.

@bkobkobko
Copy link
Contributor

Hi @stewartadam

I am not sure what is up with this pull req, but I did want to make two points:

  1. This pull as written would not appear to me to work correctly--it does not do the test properly.
  2. As a work-around, you can figure the status by calling retVal = udp.receivePacket(...); since it returns -1 for socket problems, 0 for nothing to get and positive values for actual bytes received.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants