for EthernetInterface library compatibility.\\ ** Unoffical fix. may be a problem. **

Dependents:   SNIC-httpclient-example SNIC-ntpclient-example

Fork of SNICInterface by muRata

Committer:
kishino
Date:
Tue Mar 25 01:42:25 2014 +0000
Revision:
12:0254eaccfda2
Parent:
8:50d2509479cd
Child:
14:54378c96d285
Refactoring of the class name

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kishino 4:99cc93fe7d88 1 /* Copyright (C) 2012 mbed.org, MIT License
kishino 4:99cc93fe7d88 2 *
kishino 4:99cc93fe7d88 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
kishino 4:99cc93fe7d88 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
kishino 4:99cc93fe7d88 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
kishino 4:99cc93fe7d88 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
kishino 4:99cc93fe7d88 7 * furnished to do so, subject to the following conditions:
kishino 4:99cc93fe7d88 8 *
kishino 4:99cc93fe7d88 9 * The above copyright notice and this permission notice shall be included in all copies or
kishino 4:99cc93fe7d88 10 * substantial portions of the Software.
kishino 4:99cc93fe7d88 11 *
kishino 4:99cc93fe7d88 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
kishino 4:99cc93fe7d88 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
kishino 4:99cc93fe7d88 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
kishino 4:99cc93fe7d88 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
kishino 4:99cc93fe7d88 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
kishino 4:99cc93fe7d88 17 */
kishino 4:99cc93fe7d88 18 #ifndef SOCKET_H_
kishino 4:99cc93fe7d88 19 #define SOCKET_H_
kishino 4:99cc93fe7d88 20
kishino 12:0254eaccfda2 21 #include "SNIC_Core.h"
kishino 12:0254eaccfda2 22 #include "SNIC_UartMsgUtil.h"
kishino 4:99cc93fe7d88 23
kishino 4:99cc93fe7d88 24 typedef unsigned long socklen_t;
kishino 4:99cc93fe7d88 25
kishino 4:99cc93fe7d88 26 namespace murata_wifi
kishino 4:99cc93fe7d88 27 {
kishino 4:99cc93fe7d88 28
kishino 12:0254eaccfda2 29 #define SNIC_UART_RECVBUF_SIZE 2048
kishino 12:0254eaccfda2 30
kishino 4:99cc93fe7d88 31 /** Socket file descriptor and select wrapper
kishino 4:99cc93fe7d88 32 */
kishino 4:99cc93fe7d88 33 class Socket {
kishino 4:99cc93fe7d88 34 public:
kishino 4:99cc93fe7d88 35 /** Socket
kishino 4:99cc93fe7d88 36 */
kishino 4:99cc93fe7d88 37 Socket();
kishino 4:99cc93fe7d88 38
kishino 4:99cc93fe7d88 39 /** Set socket options
kishino 12:0254eaccfda2 40 @param level stack level (see: lwip/sockets.h)
kishino 12:0254eaccfda2 41 @param optname option ID
kishino 12:0254eaccfda2 42 @param optval option value
kishino 12:0254eaccfda2 43 @param socklen_t length of the option value
kishino 12:0254eaccfda2 44 @return 0 on success, -1 on failure
kishino 4:99cc93fe7d88 45 */
kishino 4:99cc93fe7d88 46 int set_option(int level, int optname, const void *optval, socklen_t optlen);
kishino 4:99cc93fe7d88 47
kishino 4:99cc93fe7d88 48 /** Get socket options
kishino 12:0254eaccfda2 49 @param level stack level (see: lwip/sockets.h)
kishino 12:0254eaccfda2 50 @param optname option ID
kishino 4:99cc93fe7d88 51 \param optval buffer pointer where to write the option value
kishino 4:99cc93fe7d88 52 \param socklen_t length of the option value
kishino 4:99cc93fe7d88 53 \return 0 on success, -1 on failure
kishino 12:0254eaccfda2 54 */
kishino 4:99cc93fe7d88 55 int get_option(int level, int optname, void *optval, socklen_t *optlen);
kishino 4:99cc93fe7d88 56
kishino 4:99cc93fe7d88 57 /** Close the socket
kishino 4:99cc93fe7d88 58 \param shutdown free the left-over data in message queues
kishino 4:99cc93fe7d88 59 */
kishino 4:99cc93fe7d88 60 int close(bool shutdown=true);
kishino 4:99cc93fe7d88 61
kishino 4:99cc93fe7d88 62 ~Socket();
kishino 4:99cc93fe7d88 63
kishino 12:0254eaccfda2 64 int createSocket( unsigned char bind = 0, unsigned int local_addr = 0, unsigned short port = 0 );
kishino 12:0254eaccfda2 65
kishino 4:99cc93fe7d88 66 protected:
kishino 12:0254eaccfda2 67 int mSocketID;
kishino 12:0254eaccfda2 68 C_SNIC_Core *mSnicWifi_p;
kishino 12:0254eaccfda2 69
kishino 4:99cc93fe7d88 70 #if 0
kishino 4:99cc93fe7d88 71 bool _blocking;
kishino 4:99cc93fe7d88 72 int _timeout;
kishino 4:99cc93fe7d88 73 GSwifi * _wifi;
kishino 4:99cc93fe7d88 74
kishino 4:99cc93fe7d88 75 bool _server;
kishino 4:99cc93fe7d88 76 int _cid;
kishino 4:99cc93fe7d88 77 int _port;
kishino 4:99cc93fe7d88 78 #endif
kishino 4:99cc93fe7d88 79
kishino 4:99cc93fe7d88 80 private:
kishino 12:0254eaccfda2 81
kishino 4:99cc93fe7d88 82 // int select(struct timeval *timeout, bool read, bool write);
kishino 4:99cc93fe7d88 83 };
kishino 4:99cc93fe7d88 84 }
kishino 4:99cc93fe7d88 85
kishino 4:99cc93fe7d88 86 #endif /* SOCKET_H_ */