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: M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more
Socket/Socket.cpp@20:6e7eaf4f8634, 2013-12-17 (annotated)
- Committer:
- jengbrecht
- Date:
- Tue Dec 17 15:49:47 2013 +0000
- Revision:
- 20:6e7eaf4f8634
- Child:
- 39:6e94520a3217
Added initial version of modified Socket Package.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jengbrecht | 20:6e7eaf4f8634 | 1 | /* Copyright (C) 2012 mbed.org, MIT License |
jengbrecht | 20:6e7eaf4f8634 | 2 | * |
jengbrecht | 20:6e7eaf4f8634 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
jengbrecht | 20:6e7eaf4f8634 | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
jengbrecht | 20:6e7eaf4f8634 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
jengbrecht | 20:6e7eaf4f8634 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
jengbrecht | 20:6e7eaf4f8634 | 7 | * furnished to do so, subject to the following conditions: |
jengbrecht | 20:6e7eaf4f8634 | 8 | * |
jengbrecht | 20:6e7eaf4f8634 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
jengbrecht | 20:6e7eaf4f8634 | 10 | * substantial portions of the Software. |
jengbrecht | 20:6e7eaf4f8634 | 11 | * |
jengbrecht | 20:6e7eaf4f8634 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
jengbrecht | 20:6e7eaf4f8634 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
jengbrecht | 20:6e7eaf4f8634 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
jengbrecht | 20:6e7eaf4f8634 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
jengbrecht | 20:6e7eaf4f8634 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
jengbrecht | 20:6e7eaf4f8634 | 17 | */ |
jengbrecht | 20:6e7eaf4f8634 | 18 | |
jengbrecht | 20:6e7eaf4f8634 | 19 | #include "Socket.h" |
jengbrecht | 20:6e7eaf4f8634 | 20 | #include <cstring> |
jengbrecht | 20:6e7eaf4f8634 | 21 | |
jengbrecht | 20:6e7eaf4f8634 | 22 | Socket::Socket() : _blocking(true), _timeout(1500) { |
jengbrecht | 20:6e7eaf4f8634 | 23 | cellular = Cellular::getInstance(); |
jengbrecht | 20:6e7eaf4f8634 | 24 | } |
jengbrecht | 20:6e7eaf4f8634 | 25 | |
jengbrecht | 20:6e7eaf4f8634 | 26 | void Socket::set_blocking(bool blocking, unsigned int timeout) { |
jengbrecht | 20:6e7eaf4f8634 | 27 | _blocking = blocking; |
jengbrecht | 20:6e7eaf4f8634 | 28 | _timeout = timeout; |
jengbrecht | 20:6e7eaf4f8634 | 29 | } |
jengbrecht | 20:6e7eaf4f8634 | 30 | |
jengbrecht | 20:6e7eaf4f8634 | 31 | int Socket::close() { |
jengbrecht | 20:6e7eaf4f8634 | 32 | return (cellular->close()) ? 0 : -1; |
jengbrecht | 20:6e7eaf4f8634 | 33 | } |
jengbrecht | 20:6e7eaf4f8634 | 34 | |
jengbrecht | 20:6e7eaf4f8634 | 35 | Socket::~Socket() { |
jengbrecht | 20:6e7eaf4f8634 | 36 | close(); //Don't want to leak |
jengbrecht | 20:6e7eaf4f8634 | 37 | } |