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 C027_Support_Plus_Dialing by
Socket.h
00001 #ifndef SOCKET_H_ 00002 #define SOCKET_H_ 00003 00004 #include "MDM.h" 00005 00006 /** Socket file descriptor and select wrapper 00007 */ 00008 class Socket { 00009 public: 00010 Socket() { 00011 _socket = -1; 00012 _timeout_ms = MDMParser::TIMEOUT_BLOCKING; 00013 _mdm = NULL; 00014 } 00015 00016 void set_blocking(bool blocking, unsigned int timeout = 1500) { 00017 _timeout_ms = blocking ? MDMParser::TIMEOUT_BLOCKING : (int)timeout; 00018 if (_socket >= 0) { 00019 _mdm->socketSetBlocking(_socket, _timeout_ms); 00020 } 00021 } 00022 00023 int close() { 00024 bool ret = false; 00025 if (_socket >= 0) 00026 { 00027 ret = _mdm->socketClose(_socket); 00028 _mdm->socketFree(_socket); 00029 _socket = -1; 00030 _timeout_ms = MDMParser::TIMEOUT_BLOCKING; 00031 } 00032 return ret ? 0 : -1; 00033 } 00034 00035 ~Socket() { close(); } 00036 00037 protected: 00038 int _socket; 00039 int _timeout_ms; 00040 MDMParser* _mdm; 00041 }; 00042 00043 00044 #endif /* SOCKET_H_ */
Generated on Wed Jul 13 2022 18:14:53 by
