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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions wiring/inc/spark_wiring_udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ class UDP : public Stream, public Printable {
* @return Return the result of the leave operation
*/
int leaveMulticast(const IPAddress& ip);

/*
* let client code to check for socket validity
* @return True for a valid socket.
*/
bool isValid();


using Print::write;
};
Expand Down
5 changes: 5 additions & 0 deletions wiring/src/spark_wiring_udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,8 @@ int UDP::leaveMulticast(const IPAddress& ip)
HAL_IPAddress address = ip.raw();
return socket_leave_multicast(&address, _nif, 0);
}

bool UDP::isValid()
{
return _sock != socket_handle_invalid();
}