Temp fork

Dependents:   Seeed_GPRS_Shield

Fork of GPRSInterface by wei zou

Committer:
lawliet
Date:
Wed Feb 26 09:12:46 2014 +0000
Revision:
3:acf2ea413e72
Parent:
1:7298a7950f65
version 1.1 (fix some errors)

Who changed what in which revision?

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