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.
Fork of MQTT by
MQTTSocket.h
00001 #if !defined(MQTTSOCKET_H) 00002 #define MQTTSOCKET_H 00003 00004 #include "MQTTmbed.h" 00005 #include "TCPSocketConnection.h" 00006 00007 class MQTTSocket 00008 { 00009 public: 00010 ~MQTTSocket() 00011 { 00012 if(mysock) 00013 delete mysock; 00014 } 00015 00016 int connect(char* hostname, int port, int timeout=1000) 00017 { 00018 mysock->set_blocking(false, timeout); // 1 second Timeout 00019 return mysock->connect(hostname, port); 00020 } 00021 00022 int read(unsigned char* buffer, int len, int timeout) 00023 { 00024 mysock->set_blocking(false, timeout); 00025 return mysock->receive((char*)buffer, len); 00026 } 00027 00028 int write(unsigned char* buffer, int len, int timeout) 00029 { 00030 mysock->set_blocking(false, timeout); 00031 return mysock->send((char*)buffer, len); 00032 } 00033 00034 int disconnect() 00035 { 00036 return mysock->close(); 00037 } 00038 00039 protected: 00040 void createSocket() { mysock = new TCPSocketConnection(); } 00041 private: 00042 00043 TCPSocketConnection *mysock; 00044 00045 }; 00046 00047 00048 00049 #endif
Generated on Fri Jul 15 2022 17:16:07 by
 1.7.2
 1.7.2 
    