WizFi310Interface for mbed OS2 ( Legacy version )

Dependents:   WizFi310_Legacy_HelloWorld WizFi310_Legacy_AP_HelloWorld WizFi310_Legacy_OpenWeatherMap WizFi310_Legacy_Geolocation_NTP ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Socket.h Source File

Socket.h

00001 /*
00002  * Copyright (C) 2013 gsfan, MIT License
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00005  * and associated documentation files (the "Software"), to deal in the Software without restriction,
00006  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
00007  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00008  * furnished to do so, subject to the following conditions:
00009  *
00010  * The above copyright notice and this permission notice shall be included in all copies or
00011  * substantial portions of the Software.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00014  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00015  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00016  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00017  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00018  */
00019 /* Copyright (C) 2014 Wiznet, MIT License
00020  *  port to the Wiznet Module WizFi250
00021  */
00022 /* Copyright (C) 2017 Wiznet, MIT License
00023  *  port to the Wiznet Module WizFi310
00024  */
00025 
00026 #ifndef SOCKET_H_
00027 #define SOCKET_H_
00028 
00029 #include "WizFi310.h"
00030 
00031 /** Socket file descriptor and select wrapper
00032   */
00033 class Socket {
00034 public:
00035     /** Socket
00036      */
00037     Socket();
00038     
00039     /** Set blocking or non-blocking mode of the socket and a timeout on
00040         blocking socket operations
00041     \param blocking  true for blocking mode, false for non-blocking mode.
00042     \param timeout   timeout in ms [Default: (1500)ms].
00043     */
00044     void set_blocking(bool blocking, unsigned int timeout=1500);
00045     
00046     /** Close the socket file descriptor
00047      */
00048     int close();
00049     
00050     ~Socket();
00051     
00052 protected:
00053     bool _blocking;
00054     int _timeout;
00055     WizFi310 * _wizfi310;
00056 
00057     bool _server;
00058     int _cid;
00059     int _port;
00060 };
00061 
00062 
00063 #endif /* SOCKET_H_ */