root/branches/follower/libw5100/src/libw5100/connection.h

Revision 140, 1.2 KB (checked in by follower, 11 months ago)

Add author, license and copyright details. (Which weren't permitted in competition entry source.)

Line 
1/*
2
3   NetworkConnection
4
5   High level socket instance wrapper
6
7   Author:
8
9      Philip Lindsay <follower@rancidbacon.com>
10
11   License:
12
13      Copyright 2007-2008 // LGPL
14
15*/
16
17#ifndef _CONNECTION_H_
18#define _CONNECTION_H_
19
20// Required for use in Arduino environment
21#include <WConstants.h>
22
23// From original driver
24#include "types.h"
25#include "w5100.h"
26#include "socket.h"
27
28#include <string.h>
29
30// TODO: Make this 'NetworkServerConnection'? Or just 'ServerConnection'?
31// TODO: Pull one-line methods into class definition to allow inlining?
32class NetworkConnection { // Essentially a Socket wrapper
33
34  public:
35    // TODO: Split into client/server connections? Subclass?
36    NetworkConnection(uint16_t port); // TODO: Add UDP, TCP choice? // For servers
37    NetworkConnection(); // For clients--is using the default constructor hide misuse? TODO: As above.
38
39    int listen();
40    int connect(uint8 * addr, uint16 port);
41    int isConnected();
42    int available();
43    int read();
44    void print(uint8_t);
45    void print(const char * text);
46    void close();
47
48  private:
49    SOCKET _socket;
50    static const int _MAX_SOCKETS = MAX_SOCK_NUM; // TODO: Use this.
51    static int _nextSocket;
52};
53
54
55#endif
Note: See TracBrowser for help on using the browser.