Dependents:   W5500-SNTPClient-example

Committer:
star297
Date:
Thu May 02 20:47:25 2019 +0000
Revision:
0:e9275bdfa393
First commit

Who changed what in which revision?

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