http://mbed.org/users/gsfan/notebook/gainspan_wifi/ porterd from: http://electronics.trev.id.au/2012/02/07/gainspan-wifi-library-for-chipkit-and-arduino/

Dependencies:   mbed

Committer:
gsfan
Date:
Sun May 27 03:19:54 2012 +0000
Revision:
0:bf663118b11b

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gsfan 0:bf663118b11b 1 /*
gsfan 0:bf663118b11b 2 * Gainspan Wifi library for mbed
gsfan 0:bf663118b11b 3 * Modified for mbed, 2012 gsfan.
gsfan 0:bf663118b11b 4 *
gsfan 0:bf663118b11b 5
gsfan 0:bf663118b11b 6 socket.h - network socket class
gsfan 0:bf663118b11b 7
gsfan 0:bf663118b11b 8 Copyright (C) 2011 DIYSandbox LLC
gsfan 0:bf663118b11b 9
gsfan 0:bf663118b11b 10 This program is free software; you can redistribute it and/or
gsfan 0:bf663118b11b 11 modify it under the terms of the GNU General Public License
gsfan 0:bf663118b11b 12 as published by the Free Software Foundation; either version 2
gsfan 0:bf663118b11b 13 of the License, or (at your option) any later version.
gsfan 0:bf663118b11b 14
gsfan 0:bf663118b11b 15 This program is distributed in the hope that it will be useful,
gsfan 0:bf663118b11b 16 but WITHOUT ANY WARRANTY; without even the implied warranty of
gsfan 0:bf663118b11b 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
gsfan 0:bf663118b11b 18 GNU General Public License for more details.
gsfan 0:bf663118b11b 19
gsfan 0:bf663118b11b 20 You should have received a copy of the GNU General Public License
gsfan 0:bf663118b11b 21 along with this program; if not, write to the Free Software
gsfan 0:bf663118b11b 22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
gsfan 0:bf663118b11b 23 */
gsfan 0:bf663118b11b 24
gsfan 0:bf663118b11b 25 #ifndef _socket_h_
gsfan 0:bf663118b11b 26 #define _socket_h_
gsfan 0:bf663118b11b 27
gsfan 0:bf663118b11b 28 #include "mbed.h"
gsfan 0:bf663118b11b 29 #include "gs.h"
gsfan 0:bf663118b11b 30
gsfan 0:bf663118b11b 31 #define MAX_SOCK_NUM 4
gsfan 0:bf663118b11b 32
gsfan 0:bf663118b11b 33 class GSSocket : public GSClass {
gsfan 0:bf663118b11b 34 public:
gsfan 0:bf663118b11b 35 GSSocket(PinName p_tx, PinName p_rx) : GSClass(p_tx, p_rx) {};
gsfan 0:bf663118b11b 36 GSSocket(PinName p_tx, PinName p_rx, PinName p_cts, PinName p_rts) : GSClass(p_tx, p_rx, p_cts, p_rts) {};
gsfan 0:bf663118b11b 37
gsfan 0:bf663118b11b 38 int socket(SOCKET s, int protocol, int port, int flag); // Opens a socket(TCP or UDP or IP_RAW mode)
gsfan 0:bf663118b11b 39 void close(SOCKET s); // Close socket
gsfan 0:bf663118b11b 40 int listen(SOCKET s); // Establish TCP connection (Passive connection)
gsfan 0:bf663118b11b 41 int recv(SOCKET s, uint8_t *buf, int len); // Receive data (TCP)
gsfan 0:bf663118b11b 42 void disconnect(SOCKET s);
gsfan 0:bf663118b11b 43 int send(SOCKET s, const uint8_t *buf, int len); // Send data (TCP)
gsfan 0:bf663118b11b 44 int connect(SOCKET s, Host &host);
gsfan 0:bf663118b11b 45
gsfan 0:bf663118b11b 46 private:
gsfan 0:bf663118b11b 47 int local_port;
gsfan 0:bf663118b11b 48
gsfan 0:bf663118b11b 49 };
gsfan 0:bf663118b11b 50
gsfan 0:bf663118b11b 51
gsfan 0:bf663118b11b 52 #endif // _socket_h_