This is WIZnet Ethernet Interface using Hardware TCP/IP chip, W5500, W5200 and W5100. One of them can be selected by enabling it in wiznet.h.

Dependents:   EZS

Fork of WIZnet_Library by WIZnet

Committer:
Vektor
Date:
Wed Aug 08 09:45:44 2018 +0000
Revision:
9:45167b342fec
Parent:
7:7c67a8922ec5
Change default chip to 5100

Who changed what in which revision?

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