From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7bf7c8b2f1e437b,start X-Google-Attributes: gid103376,public From: "Richard Y. C. Lee" Subject: Ada interface to Jave network socket Date: 2000/05/28 Message-ID: <3930B462.66199B57@compuserve.com>#1/1 X-Deja-AN: 628162920 X-Accept-Language: en Content-Type: multipart/mixed; boundary="------------F1C499B3A27C395AB57F8212" X-Complaints-To: newsmaster@compuserve.com X-Trace: sshuraab-i-1.production.compuserve.com 959493148 29575 63.12.28.19 (28 May 2000 05:52:28 GMT) Organization: Marivel Pty Limited Mime-Version: 1.0 NNTP-Posting-Date: 28 May 2000 05:52:28 GMT Newsgroups: comp.lang.ada Date: 2000-05-28T05:52:28+00:00 List-Id: This is a multi-part message in MIME format. --------------F1C499B3A27C395AB57F8212 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I am doing Software Engineering at university. Currently I am working on an elevator control project which require writing Ada code to interface with Java. The interface is through a tcp socket connection. The Ada code is to connect with a network socket created in Java then pass messages across. Enclosed sample Java code which creates the socket. Anyone with some ideas how this is done would be appreciated. Richard --------------F1C499B3A27C395AB57F8212 Content-Type: text/plain; charset=us-ascii; name="ManagerConnect.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ManagerConnect.java" //Title: Elevator System //Version: //Copyright: Copyright (c) 2000 //Author: David Lowe //Company: Faculty of Engineering, UTS //Description:48440: Software Engineering // Major Project // Elevator Simulator //Filename: ManagerConnect.java import java.awt.*; import java.io.*; import java.util.*; import java.net.*; public class ManagerConnect implements Runnable { String className = "ManagerConnect"; ElevatorController elevCont; int elevNum; int elevPort; boolean verbose; // Time information Thread ThreadManIF; // Constructor public ManagerConnect(ElevatorController elevCont, int port, boolean verbose, int elevNum) { this.elevCont = elevCont; this.elevPort = port; this.verbose = verbose; this.elevNum = elevNum; // Start the Manager Interface thread ThreadManIF = new Thread(this, "ThreadManIF"); ThreadManIF.start(); System.out.println(className + ": Manager Interface constructed and running"); } // Main thread routine public void run() { ServerSocket server; Socket connection; String request, response; DataInputStream ip; DataOutputStream op; byte buf[] = new byte[1000]; int numread; try { // create the socket for the server server = new ServerSocket( elevPort, 100 ); System.out.println(className + ": Manager Socket set up on port " + elevPort); while (true) { // wait for a connection connection = server.accept(); ip = new DataInputStream(connection.getInputStream()); op = new DataOutputStream(connection.getOutputStream()); System.out.println(className + ": Connection established on port " + elevPort); // get messages and respond do { // read in the command numread = ip.read(buf); request = new String(buf, 0, numread); // process request // ### NOTE THIS NEEDS TO BE FINISHED - ALSO NEED TO MAKE // ### IT MULTITHREADING SO CAN HANDLE MULTIPLE OPERATOR // ### CONNECTIONS response = "Fail"; // send the response if (verbose) System.out.println(className + ": request <" + request + "> - response <" + response + ">"); op.write(response.getBytes()); op.flush(); } while (true); } } catch (IOException e) { e.printStackTrace(); } } } --------------F1C499B3A27C395AB57F8212--