From 265a634089b9e4cc2935f22e62509dbd15b29a85 Mon Sep 17 00:00:00 2001 From: follower Date: Tue, 11 Dec 2007 11:28:39 +0000 Subject: [PATCH] If the connection 'listen' method fails we bail into an infinite loop. TODO: Provide a way for the caller to detect and handle this kind of error? git-svn-id: svn+ssh://oldsvn/home/mlalondesvn/svn/cral@110 3ee9b42a-b53c-0410-a25e-f0b6218d5d5b --- .../wiz810mj/src/demo/WizDemo4/WizDemo4.pde | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/branches/follower/wiz810mj/src/demo/WizDemo4/WizDemo4.pde b/branches/follower/wiz810mj/src/demo/WizDemo4/WizDemo4.pde index 3dc7aee..a4f3416 100644 --- a/branches/follower/wiz810mj/src/demo/WizDemo4/WizDemo4.pde +++ b/branches/follower/wiz810mj/src/demo/WizDemo4/WizDemo4.pde @@ -217,7 +217,6 @@ void Wiz810MjDevice::setMac(byte b0, byte b1, byte b2, byte b3, byte b4, byte b5 /* ---- NetworkConnection ---- */ - // TODO: Make this 'NetworkServerConnection'? Or just 'ServerConnection'? // TODO: Pull one-line methods into class definition to allow inlining? class NetworkConnection { // Essentially a Socket wrapper @@ -283,6 +282,8 @@ void NetworkConnection::close() { /* -- NetworkInterface -- */ +#define HANDLE_BAD_ERROR() while (1) {}; + // TODO?: Do we want to have a "default" socket accessible by 'Network.read()' etc? class NetworkInterface { @@ -334,7 +335,15 @@ NetworkConnection NetworkInterface::listen(uint16_t port) { */ NetworkConnection connection = NetworkConnection(port); - connection.listen(); + // TODO: How to best handle errors? + // There's two major categories I can think of currently: + // 1) A socket wasn't available to listen in the first place + // 2) The listen attempt failed for some reason + // Using 'HANDLE_BAD_ERROR()' (currently an infinite loop) is + // not ideal but should prevent the above errors slipping by unnoticed. + if (!connection.listen()) { + HANDLE_BAD_ERROR(); + } return connection; }