Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: HelloWizFi250Interface
Fork of NetworkSocketAPI by
Revision 38:157fb2ab965f, committed 2016-02-22
- Comitter:
- Christopher Haster
- Date:
- Mon Feb 22 20:51:09 2016 -0600
- Branch:
- api-changes
- Parent:
- 37:50b481a8e784
- Child:
- 39:47138420ea42
- Commit message:
- Added isConnected method to Socket/SocketInterface
Changed in this revision
--- a/Socket.cpp Tue Feb 23 17:35:56 2016 +0000
+++ b/Socket.cpp Mon Feb 22 20:51:09 2016 -0600
@@ -71,6 +71,15 @@
return _port;
}
+bool Socket::isConnected()
+{
+ if (!_socket) {
+ return false;
+ }
+
+ return _socket->isConnected();
+}
+
int32_t Socket::open(const char *url, uint16_t port)
{
if (_socket) {
--- a/Socket.h Tue Feb 23 17:35:56 2016 +0000
+++ b/Socket.h Mon Feb 22 20:51:09 2016 -0600
@@ -53,6 +53,11 @@
*/
uint16_t getPort() const;
+ /** Returns status of socket
+ * @return true if connected
+ */
+ bool isConnected();
+
/** Open a connection to the underlying address
* @param url Optional URL or IP address to connect to
--- a/SocketInterface.cpp Tue Feb 23 17:35:56 2016 +0000
+++ b/SocketInterface.cpp Mon Feb 22 20:51:09 2016 -0600
@@ -15,7 +15,14 @@
*/
#include "SocketInterface.h"
-
+
+// By default setIPAddress/setPort has no special behaviour
void SocketInterface::setIPAddress(const char *ip) {}
void SocketInterface::setPort(uint16_t port) {}
+// By default isConnected is always true if the socket
+// was created successfully
+bool SocketInterface::isConnected() {
+ return true;
+}
+
--- a/SocketInterface.h Tue Feb 23 17:35:56 2016 +0000
+++ b/SocketInterface.h Mon Feb 22 20:51:09 2016 -0600
@@ -46,6 +46,11 @@
*/
virtual void setPort(uint16_t port);
+ /** Status of the socket
+ * @return True if connected
+ */
+ virtual bool isConnected();
+
/** Open a connection to the underlying address
* @param ip IP address to connect to
* @param port Port to connect to
