Add initial skeleton of the plain socket wrapping 'NetworkConnection' class--it is not yet used though.

git-svn-id: svn+ssh://oldsvn/home/mlalondesvn/svn/cral@101 3ee9b42a-b53c-0410-a25e-f0b6218d5d5b
master
follower 17 years ago
parent 228508d0a9
commit 45481088d4

@ -215,12 +215,45 @@ void Wiz810MjDevice::setMac(byte b0, byte b1, byte b2, byte b3, byte b4, byte b5
/* ----------------------- */ /* ----------------------- */
/* ---- NetworkConnection ---- */
// TODO: Make this 'NetworkServerConnection'? Or just 'ServerConnection'?
class NetworkConnection { // Essentially a Socket wrapper
public:
NetworkConnection(uint8_t port); // TODO: Add UDP, TCP choice?
void listen(); // TODO: Return a useful value?
private:
SOCKET _socket;
};
NetworkConnection::NetworkConnection(uint8_t port) {
/*
*/
socket(_socket, Sn_MR_TCP, port, 0);
}
void NetworkConnection::listen() { // TODO: Make private or protected?
/*
*/
::listen(_socket); // TODO: Use C++ namespaces for the driver functions?
}
/* ----------------------- */
/* -- NetworkInterface -- */ /* -- NetworkInterface -- */
class NetworkInterface { class NetworkInterface {
public: public:
NetworkInterface(Wiz810MjDevice& networkDevice); NetworkInterface(Wiz810MjDevice& networkDevice);
NetworkConnection listen(uint8_t port);
Wiz810MjDevice& device; // TODO: Make this a generic "network device" interface Wiz810MjDevice& device; // TODO: Make this a generic "network device" interface
}; };
@ -247,11 +280,24 @@ NetworkInterface::NetworkInterface(Wiz810MjDevice& networkDevice) : device (netw
}; };
NetworkConnection NetworkInterface::listen(uint8_t port) {
/*
Returns a NetworkConnection listening on the specified TCP port.
*/
NetworkConnection connection = NetworkConnection(port);
connection.listen();
return connection;
}
// NetworkInterface Network = NetworkInterface(...); // TODO: Make this a global // NetworkInterface Network = NetworkInterface(...); // TODO: Make this a global
/* ----------------------- */ /* ----------------------- */
// #define PIN_RESET 9 // WIZnet module /RESET // #define PIN_RESET 9 // WIZnet module /RESET
#define PIN_RESET 8 // WIZnet module /RESET #define PIN_RESET 8 // WIZnet module /RESET

Loading…
Cancel
Save