Changeset 878
- Timestamp:
- 02/11/14 22:16:48 (10 years ago)
- Location:
- trunk/src/org/expeditee/network
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/network/DefaultServer.java
r838 r878 58 58 //MessageBay.displayMessage(this.getName() + " started on port " 59 59 // + socket.getLocalPort()); 60 int fail = 0; 60 61 61 62 while (!_stop) { 62 63 try { 63 64 listenForMessages(); 64 65 fail = 0; 65 66 } catch (IOException e) { 66 67 e.printStackTrace(); 68 } catch (Exception e) { 69 /** 70 * If we hit an Exception we don't want to crash, 71 * but we also don't want to get into an infinite loop of ignoring fatal exceptions. 72 * so try again but count the failures to make sure we don't get into an infinite loop. 73 * (don't just use a boolean because the next message we parse could also cause another 74 * non-fatal exception, and we don't want to exit unless absolutely necessary) 75 */ 76 e.printStackTrace(); 77 if(fail > 10) { 78 System.out.println("*****\nIt appears that we've failed to continue from an uncaught exception\n*****"); 79 // close all the servers 80 FrameShare.getInstance().finalise(); 81 // attempt to restart 82 // (don't do this yet since there's currently no way to know if the restart fails, 83 // so we could get stuck in a loop) 84 // FrameShare.restart(); 85 86 // if we're only running the frameshare server, exit 87 if(FrameShare.isHeadless()) { 88 System.exit(1); 89 } 90 } else { 91 fail++; 92 System.out.println("*****\nEncountered an uncaught exception, attempting to continue\n*****"); 93 } 67 94 } 68 95 } 96 97 closeSocket(); 98 } 99 100 protected void closeSocket() { 69 101 socket.close(); 70 102 } -
trunk/src/org/expeditee/network/FrameShare.java
r856 r878 43 43 44 44 private static FrameShare _theSession; 45 46 private static boolean headless = false; 45 47 46 48 private Map<String, Peer> _peers; … … 511 513 } 512 514 } 515 516 public static void restart() { 517 if(_theSession != null) { 518 _theSession.finalise(); 519 _theSession = new FrameShare(_theSession._port); 520 } 521 } 522 523 public static boolean isHeadless() { 524 return headless; 525 } 513 526 514 527 … … 535 548 536 549 String port_str = args[0]; 550 551 FrameShare.headless = true; 537 552 538 553 try { -
trunk/src/org/expeditee/network/ImageSaver.java
r856 r878 113 113 114 114 @Override 115 public void run() { 116 //MessageBay.displayMessage(this.getName() + " started on port " 117 // + socket.getLocalPort()); 118 119 while (!_stop) { 120 try { 121 listenForMessages(); 122 123 } catch (IOException e) { 124 e.printStackTrace(); 125 } 115 protected void closeSocket() { 116 try { 117 socket.close(); 118 } catch (IOException e) { 119 e.printStackTrace(); 126 120 } 127 try {128 socket.close();129 } catch (IOException e) {130 e.printStackTrace();131 }132 121 } 133 134 122 } -
trunk/src/org/expeditee/network/ImageServer.java
r856 r878 91 91 92 92 @Override 93 public void run() { 94 //MessageBay.displayMessage(this.getName() + " started on port " 95 // + socket.getLocalPort()); 96 97 while (!_stop) { 98 try { 99 listenForMessages(); 100 101 } catch (IOException e) { 102 e.printStackTrace(); 103 } 93 protected void closeSocket() { 94 try { 95 socket.close(); 96 } catch (IOException e) { 97 e.printStackTrace(); 104 98 } 105 try {106 socket.close();107 } catch (IOException e) {108 e.printStackTrace();109 }110 99 } 111 100
Note:
See TracChangeset
for help on using the changeset viewer.