Freedman v2

Dependents:   Freedman_v2

Fork of WizFi250Interface by DongEun Koak

Committer:
Ricky_Kwon
Date:
Wed Aug 26 07:55:34 2015 +0000
Revision:
19:502d9c5a0053
Parent:
10:187e3fd24123
Freedman v2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kaizen 0:f2039204c8f6 1 /* Copyright (C) 2012 mbed.org, MIT License
kaizen 0:f2039204c8f6 2 *
kaizen 0:f2039204c8f6 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
kaizen 0:f2039204c8f6 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
kaizen 0:f2039204c8f6 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
kaizen 0:f2039204c8f6 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
kaizen 0:f2039204c8f6 7 * furnished to do so, subject to the following conditions:
kaizen 0:f2039204c8f6 8 *
kaizen 0:f2039204c8f6 9 * The above copyright notice and this permission notice shall be included in all copies or
kaizen 0:f2039204c8f6 10 * substantial portions of the Software.
kaizen 0:f2039204c8f6 11 *
kaizen 0:f2039204c8f6 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
kaizen 0:f2039204c8f6 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
kaizen 0:f2039204c8f6 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
kaizen 0:f2039204c8f6 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
kaizen 0:f2039204c8f6 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
kaizen 0:f2039204c8f6 17 */
kaizen 0:f2039204c8f6 18 /* Copyright (C) 2014 Wiznet, MIT License
kaizen 0:f2039204c8f6 19 * port to the Wiznet Module WizFi250
kaizen 0:f2039204c8f6 20 */
kaizen 0:f2039204c8f6 21
kaizen 0:f2039204c8f6 22 #include "Socket.h"
kaizen 0:f2039204c8f6 23 #include <cstring>
kaizen 0:f2039204c8f6 24
kaizen 0:f2039204c8f6 25 Socket::Socket() {
kaizen 10:187e3fd24123 26 _wizfi250 = NULL;
kaizen 0:f2039204c8f6 27 _wizfi250 = WizFi250::getInstance();
kaizen 0:f2039204c8f6 28 if (_wizfi250 == NULL)
kaizen 0:f2039204c8f6 29 error("Socket constructor error: no WizFi250 instance available!\r\n");
kaizen 0:f2039204c8f6 30 _blocking = true;
kaizen 0:f2039204c8f6 31 _timeout = 1500;
kaizen 0:f2039204c8f6 32
kaizen 0:f2039204c8f6 33 _server = false;
kaizen 0:f2039204c8f6 34 _cid = -1;
kaizen 0:f2039204c8f6 35 _port = 0;
kaizen 0:f2039204c8f6 36 }
kaizen 0:f2039204c8f6 37
kaizen 0:f2039204c8f6 38 void Socket::set_blocking(bool blocking, unsigned int timeout) {
kaizen 0:f2039204c8f6 39 _blocking = blocking;
kaizen 0:f2039204c8f6 40 _timeout = timeout;
kaizen 0:f2039204c8f6 41 }
kaizen 0:f2039204c8f6 42
kaizen 0:f2039204c8f6 43 int Socket::close() {
kaizen 0:f2039204c8f6 44 if (_cid < 0) return 0;
kaizen 0:f2039204c8f6 45
kaizen 0:f2039204c8f6 46 _wizfi250->close(_cid);
kaizen 0:f2039204c8f6 47 _cid = -1;
kaizen 0:f2039204c8f6 48 return 0;
kaizen 0:f2039204c8f6 49 }
kaizen 0:f2039204c8f6 50
kaizen 0:f2039204c8f6 51 Socket::~Socket() {
kaizen 0:f2039204c8f6 52 close(); //Don't want to leak
kaizen 0:f2039204c8f6 53 }