Source code: com/ciphercore/samples/ChildDemo.java
1 /* $Id: ChildDemo.java,v 1.2 2001/04/02 08:42:50 cvsbob Exp $ */
2
3 /*
4 * ChildDemo.java, demonstrates a simple ciphercore child process.
5 * Copyright (C) 2001 Robert Bushman.
6 *
7 * I reserve the right to release this program under seperate license.
8 * If you require a special license grant contact Robert Bushman.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 * 02111-1307, USA.
24 */
25
26 package com.ciphercore.samples;
27
28 import java.io.DataInputStream;
29 import java.io.DataOutputStream;
30 import java.io.IOException;
31
32 import com.ciphercore.Child;
33
34 public class ChildDemo extends Child {
35
36 // -------------------------------------------------------------
37 // CHILD IMPLEMENTATION
38 // -------------------------------------------------------------
39
40 public void handleClient() {
41 try {
42 DataInputStream in = new DataInputStream( getBaseInputStream() );
43 DataOutputStream out = new DataOutputStream( getBaseOutputStream() );
44
45 String testString = "This is ground control to Major Tom";
46
47 out.writeInt( 3232 );
48 out.writeInt( testString.getBytes().length );
49 out.write( testString.getBytes() );
50 out.writeInt( 6464 );
51 out.flush();
52
53 System.out.println( "int 1: " + in.readInt() );
54 int testStringLength = in.readInt();
55 System.out.println( "String Length: " + testStringLength );
56 byte[] testStringBytes = new byte[ testStringLength ];
57 in.readFully( testStringBytes );
58 System.out.println( "Test String; " + new String(testStringBytes) );
59 System.out.println( "int 2: " + in.readInt() );
60 } catch( IOException e ) {
61 e.printStackTrace();
62 }
63 }
64
65 public boolean accessRestricted() {
66 return( false );
67 }
68 }
69