You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.2 KiB
56 lines
1.2 KiB
/*
|
|
|
|
NetworkConnection
|
|
|
|
High level socket instance wrapper
|
|
|
|
Author:
|
|
|
|
Philip Lindsay <follower@rancidbacon.com>
|
|
|
|
License:
|
|
|
|
Copyright 2007-2008 // LGPL
|
|
|
|
*/
|
|
|
|
#ifndef _CONNECTION_H_
|
|
#define _CONNECTION_H_
|
|
|
|
// Required for use in Arduino environment
|
|
#include <WConstants.h>
|
|
|
|
// From original driver
|
|
#include "types.h"
|
|
#include "w5100.h"
|
|
#include "socket.h"
|
|
|
|
#include <string.h>
|
|
|
|
// TODO: Make this 'NetworkServerConnection'? Or just 'ServerConnection'?
|
|
// TODO: Pull one-line methods into class definition to allow inlining?
|
|
class NetworkConnection { // Essentially a Socket wrapper
|
|
|
|
public:
|
|
// TODO: Split into client/server connections? Subclass?
|
|
NetworkConnection(uint16_t port); // TODO: Add UDP, TCP choice? // For servers
|
|
NetworkConnection(); // For clients--is using the default constructor hide misuse? TODO: As above.
|
|
|
|
int listen();
|
|
int connect(uint8 * addr, uint16 port);
|
|
int isConnected();
|
|
int available();
|
|
int read();
|
|
void print(uint8_t);
|
|
void print(const char * text);
|
|
void close();
|
|
|
|
private:
|
|
SOCKET _socket;
|
|
static const int _MAX_SOCKETS = MAX_SOCK_NUM; // TODO: Use this.
|
|
static int _nextSocket;
|
|
};
|
|
|
|
|
|
#endif
|