Changeset 110

Show
Ignore:
Timestamp:
12/11/07 03:28:39 (12 months ago)
Author:
follower
Message:

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?

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/follower/wiz810mj/src/demo/WizDemo4/WizDemo4.pde

    r109 r110  
    218218/* ---- NetworkConnection ---- */ 
    219219 
    220  
    221220// TODO: Make this 'NetworkServerConnection'? Or just 'ServerConnection'? 
    222221// TODO: Pull one-line methods into class definition to allow inlining? 
     
    283282 
    284283/* --  NetworkInterface -- */ 
     284 
     285#define HANDLE_BAD_ERROR() while (1) {}; 
    285286 
    286287// TODO?: Do we want to have a "default" socket accessible by 'Network.read()' etc? 
     
    335336    NetworkConnection connection = NetworkConnection(port); 
    336337     
    337     connection.listen(); 
     338    // TODO: How to best handle errors? 
     339    //       There's two major categories I can think of currently: 
     340    //         1) A socket wasn't available to listen in the first place 
     341    //         2) The listen attempt failed for some reason 
     342    //       Using 'HANDLE_BAD_ERROR()' (currently an infinite loop) is 
     343    //       not ideal but should prevent the above errors slipping by unnoticed. 
     344    if (!connection.listen()) { 
     345      HANDLE_BAD_ERROR();  
     346    } 
    338347     
    339348    return connection;