no chance
Fork of WIZnet_Library by
WIZnetInterface/Socket/Socket.cpp@3:53191b0b1f16, 2014-07-01 (annotated)
- Committer:
- Ademir501
- Date:
- Tue Jul 01 17:52:55 2014 +0000
- Revision:
- 3:53191b0b1f16
- Parent:
- 0:b72d22e10709
wiznet.h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ademir501 | 3:53191b0b1f16 | 1 | /* Copyright (C) 2012 mbed.org, MIT License |
Ademir501 | 3:53191b0b1f16 | 2 | * |
Ademir501 | 3:53191b0b1f16 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
Ademir501 | 3:53191b0b1f16 | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
Ademir501 | 3:53191b0b1f16 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
Ademir501 | 3:53191b0b1f16 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
Ademir501 | 3:53191b0b1f16 | 7 | * furnished to do so, subject to the following conditions: |
Ademir501 | 3:53191b0b1f16 | 8 | * |
Ademir501 | 3:53191b0b1f16 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
Ademir501 | 3:53191b0b1f16 | 10 | * substantial portions of the Software. |
Ademir501 | 3:53191b0b1f16 | 11 | * |
Ademir501 | 3:53191b0b1f16 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
Ademir501 | 3:53191b0b1f16 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
Ademir501 | 3:53191b0b1f16 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
Ademir501 | 3:53191b0b1f16 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
Ademir501 | 3:53191b0b1f16 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Ademir501 | 3:53191b0b1f16 | 17 | */ |
Ademir501 | 3:53191b0b1f16 | 18 | |
Ademir501 | 3:53191b0b1f16 | 19 | #include "Socket.h" |
jbkim | 0:b72d22e10709 | 20 | |
Ademir501 | 3:53191b0b1f16 | 21 | Socket::Socket() : _sock_fd(-1),_blocking(true), _timeout(1) { |
Ademir501 | 3:53191b0b1f16 | 22 | eth = WIZnet_Chip::getInstance(); |
Ademir501 | 3:53191b0b1f16 | 23 | if (eth == NULL) { |
Ademir501 | 3:53191b0b1f16 | 24 | error("Socket constructor error: no W5500 instance available!\r\n"); |
Ademir501 | 3:53191b0b1f16 | 25 | } |
Ademir501 | 3:53191b0b1f16 | 26 | } |
Ademir501 | 3:53191b0b1f16 | 27 | |
Ademir501 | 3:53191b0b1f16 | 28 | void Socket::set_blocking(bool blocking, unsigned int timeout) { |
Ademir501 | 3:53191b0b1f16 | 29 | _blocking = blocking; |
Ademir501 | 3:53191b0b1f16 | 30 | _timeout = timeout; |
Ademir501 | 3:53191b0b1f16 | 31 | } |
Ademir501 | 3:53191b0b1f16 | 32 | |
Ademir501 | 3:53191b0b1f16 | 33 | int Socket::close() { |
Ademir501 | 3:53191b0b1f16 | 34 | return (eth->close(_sock_fd)) ? 0 : -1; |
Ademir501 | 3:53191b0b1f16 | 35 | } |
Ademir501 | 3:53191b0b1f16 | 36 | |
Ademir501 | 3:53191b0b1f16 | 37 | Socket::~Socket() { |
Ademir501 | 3:53191b0b1f16 | 38 | close(); //Don't want to leak |
Ademir501 | 3:53191b0b1f16 | 39 | } |
Ademir501 | 3:53191b0b1f16 | 40 |