Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

49
LINES

< > BotCompany Repo | #1000699 // THIS is a database.

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (2124L/16K/49K).

1  
!636
2  
!modern
3  
4  
main {
5  
  static new L<S> database;
6  
  
7  
  static PrintWriter out;
8  
  static BufferedReader in;
9  
  
10  
  psvm {
11  
    ServerSocket ss = new ServerSocket(8888);
12  
    print("port 8888 yo");
13  
    while (true) {
14  
      print("and again!");
15  
      Socket clientSocket = ss.accept();
16  
      print("bing!");
17  
      out = new PrintWriter(clientSocket.getOutputStream(), true);
18  
      in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
19  
      //out.println("Hello!");
20  
      try {
21  
        onClient();
22  
      } catch (RuntimeException e) { // don't die policy except on OutOfMemoryError (bad)
23  
        e.printStackTrace();
24  
      }
25  
      print("zap.........");
26  
      clientSocket.close();
27  
    }
28  
  }
29  
  
30  
  static S read_line_from_client() ctex { // we don't like "IOExceptions"
31  
    return in.readLine();
32  
  }
33  
  
34  
  static void write_to_client(S s) {
35  
    out.println(s);
36  
  }
37  
  
38  
  static void disconnect_from_client() {
39  
    // we do it anyway when the code is through
40  
  }
41  
42  
  static void onClient() {
43  
    S s = read_line_from_client();
44  
    database.add(s);
45  
    print(quote(s) + "... oh yeah.");
46  
    write_to_client("Thank you. You are number " + database.size() + " in our system.");
47  
    disconnect_from_client();
48  
  }
49  
}

Author comment

Began life as a copy of #1000698

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000699
Snippet name: THIS is a database.
Eternal ID of this version: #1000699/1
Text MD5: 2144c959e1c8f276508c5e57ceb64015
Transpilation MD5: 2b68d2f8a51020a11f66103737d0b69e
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-23 00:22:56
Source code size: 1270 bytes / 49 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 545 / 569
Referenced in: [show references]