| 1 |
/* |
| 2 |
* *************************************************************************** |
| 3 |
* MALOC = < Minimal Abstraction Layer for Object-oriented C > |
| 4 |
* Copyright (C) 1994-- Michael Holst |
| 5 |
* |
| 6 |
* This library is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU Lesser General Public |
| 8 |
* License as published by the Free Software Foundation; either |
| 9 |
* version 2.1 of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This library is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
* Lesser General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Lesser General Public |
| 17 |
* License along with this library; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 |
* |
| 20 |
* rcsid="$Id: goj.java,v 1.6 2010/08/12 05:40:41 fetk Exp $" |
| 21 |
* *************************************************************************** |
| 22 |
*/ |
| 23 |
|
| 24 |
/* |
| 25 |
* *************************************************************************** |
| 26 |
* File: goj.java |
| 27 |
* |
| 28 |
* Purpose: Test Java interaction with the MALOC library. |
| 29 |
* |
| 30 |
* Author: Michael Holst |
| 31 |
* *************************************************************************** |
| 32 |
*/ |
| 33 |
|
| 34 |
import java.net.*; |
| 35 |
import java.io.*; |
| 36 |
|
| 37 |
public class goj { |
| 38 |
|
| 39 |
public static void main(String[] args) { |
| 40 |
|
| 41 |
int VPORTNUMBER = 14916; /* portbase; 5000 < VPORTNUMBER < 49152 */ |
| 42 |
|
| 43 |
Socket theSocket; |
| 44 |
String hostname; |
| 45 |
PrintStream theOutputStream; |
| 46 |
|
| 47 |
hostname = "localhost"; |
| 48 |
try { |
| 49 |
System.out.print("Connecting socket.."); |
| 50 |
theSocket = new Socket(hostname, VPORTNUMBER + 1); |
| 51 |
theOutputStream = new PrintStream(theSocket.getOutputStream()); |
| 52 |
System.out.print("..sending data.."); |
| 53 |
|
| 54 |
theOutputStream.println("bhsingle"); |
| 55 |
theOutputStream.println("putl 3"); |
| 56 |
theOutputStream.println("0.0 1.0 0.0"); |
| 57 |
theOutputStream.println("0.0 0.0 1.0"); |
| 58 |
theOutputStream.println("0.0 0.0 0.0"); |
| 59 |
theOutputStream.println("list 7"); |
| 60 |
theOutputStream.println("fill 2 3"); |
| 61 |
theOutputStream.println("0.0 1.0 0.0"); |
| 62 |
theOutputStream.println("0.0 0.0 1.0"); |
| 63 |
theOutputStream.println("0.5 0.5 0.5"); |
| 64 |
theOutputStream.println("fill 3 3"); |
| 65 |
theOutputStream.println("1.0 1.0 0.0"); |
| 66 |
theOutputStream.println("0.0 1.0 1.0"); |
| 67 |
theOutputStream.println("0.5 0.5 0.5"); |
| 68 |
theOutputStream.println("list -7"); |
| 69 |
theOutputStream.println("list 5"); |
| 70 |
theOutputStream.println("line 1 4"); |
| 71 |
theOutputStream.println("0.0 1.0 0.0"); |
| 72 |
theOutputStream.println("0.0 0.0 1.0"); |
| 73 |
theOutputStream.println("0.5 0.5 0.5"); |
| 74 |
theOutputStream.println("0.0 1.0 0.0"); |
| 75 |
theOutputStream.println("line 1 4"); |
| 76 |
theOutputStream.println("1.0 1.0 0.0"); |
| 77 |
theOutputStream.println("0.0 1.0 1.0"); |
| 78 |
theOutputStream.println("0.5 0.5 0.5"); |
| 79 |
theOutputStream.println("1.0 1.0 0.0"); |
| 80 |
theOutputStream.println("list -5"); |
| 81 |
theOutputStream.println("list 2"); |
| 82 |
theOutputStream.println("fill 2 3"); |
| 83 |
theOutputStream.println("0.0 1.0 0.0"); |
| 84 |
theOutputStream.println("0.0 0.0 1.0"); |
| 85 |
theOutputStream.println("0.5 0.5 0.5"); |
| 86 |
theOutputStream.println("list -2"); |
| 87 |
theOutputStream.println("list 3"); |
| 88 |
theOutputStream.println("fill 3 3"); |
| 89 |
theOutputStream.println("1.0 1.0 0.0"); |
| 90 |
theOutputStream.println("0.0 1.0 1.0"); |
| 91 |
theOutputStream.println("0.5 0.5 0.5"); |
| 92 |
theOutputStream.println("list -3"); |
| 93 |
theOutputStream.println("putl -1"); |
| 94 |
|
| 95 |
System.out.print("..closing socket.."); |
| 96 |
theSocket.close(); |
| 97 |
System.out.print("..done.\n"); |
| 98 |
} |
| 99 |
catch (UnknownHostException e) { |
| 100 |
System.err.println(e); |
| 101 |
} |
| 102 |
catch (IOException e) { |
| 103 |
System.err.println(e); |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
|