Final Code 12/19/2015

Dependents:   DCS_FINAL_CODE

Committer:
DeWayneDennis
Date:
Sat Dec 19 21:57:34 2015 +0000
Revision:
0:b49935f48132
Final Code 12/19/2015

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DeWayneDennis 0:b49935f48132 1 /*
DeWayneDennis 0:b49935f48132 2 Socket.cpp
DeWayneDennis 0:b49935f48132 3 2014 Copyright (c) Seeed Technology Inc. All right reserved.
DeWayneDennis 0:b49935f48132 4
DeWayneDennis 0:b49935f48132 5 Author:lawliet zou(lawliet.zou@gmail.com)
DeWayneDennis 0:b49935f48132 6 2014-2-24
DeWayneDennis 0:b49935f48132 7
DeWayneDennis 0:b49935f48132 8 This library is free software; you can redistribute it and/or
DeWayneDennis 0:b49935f48132 9 modify it under the terms of the GNU Lesser General Public
DeWayneDennis 0:b49935f48132 10 License as published by the Free Software Foundation; either
DeWayneDennis 0:b49935f48132 11 version 2.1 of the License, or (at your option) any later version.
DeWayneDennis 0:b49935f48132 12
DeWayneDennis 0:b49935f48132 13 This library is distributed in the hope that it will be useful,
DeWayneDennis 0:b49935f48132 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
DeWayneDennis 0:b49935f48132 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
DeWayneDennis 0:b49935f48132 16 Lesser General Public License for more details.
DeWayneDennis 0:b49935f48132 17
DeWayneDennis 0:b49935f48132 18 You should have received a copy of the GNU Lesser General Public
DeWayneDennis 0:b49935f48132 19 License along with this library; if not, write to the Free Software
DeWayneDennis 0:b49935f48132 20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
DeWayneDennis 0:b49935f48132 21 */
DeWayneDennis 0:b49935f48132 22
DeWayneDennis 0:b49935f48132 23 #include "Socket.h"
DeWayneDennis 0:b49935f48132 24
DeWayneDennis 0:b49935f48132 25 Socket::Socket() : _sock_fd(-1) {
DeWayneDennis 0:b49935f48132 26 gprs = GPRS::getInstance();
DeWayneDennis 0:b49935f48132 27 if (gprs == NULL) {
DeWayneDennis 0:b49935f48132 28 error("Socket constructor error: no GPRS instance available!\r\n");
DeWayneDennis 0:b49935f48132 29 }
DeWayneDennis 0:b49935f48132 30 }
DeWayneDennis 0:b49935f48132 31
DeWayneDennis 0:b49935f48132 32 void Socket::set_blocking(bool blocking, unsigned int timeout)
DeWayneDennis 0:b49935f48132 33 {
DeWayneDennis 0:b49935f48132 34 //nothing to do for GPRS
DeWayneDennis 0:b49935f48132 35 }
DeWayneDennis 0:b49935f48132 36 int Socket::close() {
DeWayneDennis 0:b49935f48132 37 return (gprs->close(_sock_fd)) ? 0 : -1;
DeWayneDennis 0:b49935f48132 38 }
DeWayneDennis 0:b49935f48132 39
DeWayneDennis 0:b49935f48132 40 Socket::~Socket() {
DeWayneDennis 0:b49935f48132 41 close();
DeWayneDennis 0:b49935f48132 42 }