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