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
master
follower 17 years ago
parent 2fc2cf46a8
commit 265a634089

@ -217,7 +217,6 @@ void Wiz810MjDevice::setMac(byte b0, byte b1, byte b2, byte b3, byte b4, byte b5
/* ---- NetworkConnection ---- */ /* ---- NetworkConnection ---- */
// TODO: Make this 'NetworkServerConnection'? Or just 'ServerConnection'? // TODO: Make this 'NetworkServerConnection'? Or just 'ServerConnection'?
// TODO: Pull one-line methods into class definition to allow inlining? // TODO: Pull one-line methods into class definition to allow inlining?
class NetworkConnection { // Essentially a Socket wrapper class NetworkConnection { // Essentially a Socket wrapper
@ -283,6 +282,8 @@ void NetworkConnection::close() {
/* -- NetworkInterface -- */ /* -- NetworkInterface -- */
#define HANDLE_BAD_ERROR() while (1) {};
// TODO?: Do we want to have a "default" socket accessible by 'Network.read()' etc? // TODO?: Do we want to have a "default" socket accessible by 'Network.read()' etc?
class NetworkInterface { class NetworkInterface {
@ -334,7 +335,15 @@ NetworkConnection NetworkInterface::listen(uint16_t port) {
*/ */
NetworkConnection connection = NetworkConnection(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; return connection;
} }

Loading…
Cancel
Save