WIZnetInterface using namespace
Dependents: DualNetworkInterface-Basic
Fork of WIZnetInterface by
Socket/Socket.hpp@20:3e61863c1f67, 2015-07-14 (annotated)
- Committer:
- SteveKim
- Date:
- Tue Jul 14 10:16:16 2015 +0000
- Revision:
- 20:3e61863c1f67
- Parent:
- Socket/Socket.h@0:6f28332c466f
Dual Network Interface for mbed; - WIZwiki-W7500; - ESP8266
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SteveKim | 20:3e61863c1f67 | 1 | /* Copyright (C) 2012 mbed.org, MIT License |
SteveKim | 20:3e61863c1f67 | 2 | * |
SteveKim | 20:3e61863c1f67 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
SteveKim | 20:3e61863c1f67 | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
SteveKim | 20:3e61863c1f67 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
SteveKim | 20:3e61863c1f67 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
SteveKim | 20:3e61863c1f67 | 7 | * furnished to do so, subject to the following conditions: |
SteveKim | 20:3e61863c1f67 | 8 | * |
SteveKim | 20:3e61863c1f67 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
SteveKim | 20:3e61863c1f67 | 10 | * substantial portions of the Software. |
SteveKim | 20:3e61863c1f67 | 11 | * |
SteveKim | 20:3e61863c1f67 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
SteveKim | 20:3e61863c1f67 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
SteveKim | 20:3e61863c1f67 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
SteveKim | 20:3e61863c1f67 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
SteveKim | 20:3e61863c1f67 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
SteveKim | 20:3e61863c1f67 | 17 | */ |
SteveKim | 20:3e61863c1f67 | 18 | #ifndef SOCKET_H_ |
SteveKim | 20:3e61863c1f67 | 19 | #define SOCKET_H_ |
SteveKim | 20:3e61863c1f67 | 20 | |
SteveKim | 20:3e61863c1f67 | 21 | #include "eth_arch.hpp" |
SteveKim | 20:3e61863c1f67 | 22 | |
SteveKim | 20:3e61863c1f67 | 23 | #define htons(x) __REV16(x) |
SteveKim | 20:3e61863c1f67 | 24 | #define ntohs(x) __REV16(x) |
SteveKim | 20:3e61863c1f67 | 25 | #define htonl(x) __REV(x) |
SteveKim | 20:3e61863c1f67 | 26 | #define ntohl(x) __REV(x) |
SteveKim | 20:3e61863c1f67 | 27 | |
SteveKim | 20:3e61863c1f67 | 28 | namespace wiznet_space { |
Soohwan Kim |
0:6f28332c466f | 29 | |
SteveKim | 20:3e61863c1f67 | 30 | /** Socket file descriptor and select wrapper |
SteveKim | 20:3e61863c1f67 | 31 | */ |
SteveKim | 20:3e61863c1f67 | 32 | class Socket { |
SteveKim | 20:3e61863c1f67 | 33 | public: |
SteveKim | 20:3e61863c1f67 | 34 | /** Socket |
SteveKim | 20:3e61863c1f67 | 35 | */ |
SteveKim | 20:3e61863c1f67 | 36 | Socket(); |
SteveKim | 20:3e61863c1f67 | 37 | |
SteveKim | 20:3e61863c1f67 | 38 | /** Set blocking or non-blocking mode of the socket and a timeout on |
SteveKim | 20:3e61863c1f67 | 39 | blocking socket operations |
SteveKim | 20:3e61863c1f67 | 40 | \param blocking true for blocking mode, false for non-blocking mode. |
SteveKim | 20:3e61863c1f67 | 41 | \param timeout timeout in ms [Default: (1500)ms]. |
SteveKim | 20:3e61863c1f67 | 42 | */ |
SteveKim | 20:3e61863c1f67 | 43 | void set_blocking(bool blocking, unsigned int timeout=1500); |
SteveKim | 20:3e61863c1f67 | 44 | |
SteveKim | 20:3e61863c1f67 | 45 | /** Close the socket file descriptor |
SteveKim | 20:3e61863c1f67 | 46 | */ |
SteveKim | 20:3e61863c1f67 | 47 | int close(); |
SteveKim | 20:3e61863c1f67 | 48 | |
SteveKim | 20:3e61863c1f67 | 49 | ~Socket(); |
SteveKim | 20:3e61863c1f67 | 50 | |
SteveKim | 20:3e61863c1f67 | 51 | protected: |
SteveKim | 20:3e61863c1f67 | 52 | int _sock_fd; |
SteveKim | 20:3e61863c1f67 | 53 | bool _blocking; |
SteveKim | 20:3e61863c1f67 | 54 | int _timeout; |
SteveKim | 20:3e61863c1f67 | 55 | |
SteveKim | 20:3e61863c1f67 | 56 | WIZnet_Chip* eth; |
SteveKim | 20:3e61863c1f67 | 57 | }; |
SteveKim | 20:3e61863c1f67 | 58 | |
SteveKim | 20:3e61863c1f67 | 59 | } |
SteveKim | 20:3e61863c1f67 | 60 | #endif /* SOCKET_H_ */ |
SteveKim | 20:3e61863c1f67 | 61 |