.

Fork of WIZnet_Library by WIZnet

Committer:
Bongjun
Date:
Sun May 31 10:25:40 2015 +0000
Revision:
9:cb8808b47e69
Parent:
8:7c67a8922ec5
fix some codes of reading Sn_RX_RSR, Sn_TX_FSR in W5100.cpp, W5200.cpp; added is_fin_received()  in W5100, W5200 files

Who changed what in which revision?

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