?? serverhandler.java
字號:
// ============================================================================//// = PACKAGE// tests.Connection// // = FILENAME// ServerHandler.java//// = AUTHOR// Prashant Jain// // ============================================================================package JACE.tests.Connection;import java.io.*;import java.net.*;import JACE.OS.*;import JACE.Connection.*;public class ServerHandler extends SvcHandler{ public ServerHandler () { } public int open (Object obj) { new Thread (this).start (); return 0; } public void run () { int msg_len; System.out.println ("Waiting for messages..."); try { while (true) { StringBuffer msg = new StringBuffer (); msg_len = this.peer ().recv (msg); if (msg_len == 0) break; System.out.println ("Received: " + msg); this.peer ().send (new StringBuffer ("Got it!")); } } catch (NullPointerException e) { ACE.ERROR ("connection reset by peer"); } catch (IOException e) { ACE.ERROR (e); } finally { try { this.peer ().close (); } catch (IOException e) { } } }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -