Reply To: EZSrve XML Port? 2017-12-22T00:57:49+00:00

HOME Forums Gateways EZSrve EZSrve XML Port? Reply To: EZSrve XML Port?

Anonymous
Post count: 23

Paul:

Here’s the “meat” of the code. It doesn’t deal with the blocking read very well – very crude code for starters, but I can send and receive commands.

David


public void go() {
try {
Socket sock = new Socket("172.16.0.30",8002);
PrintStream ps = new PrintStream(sock.getOutputStream());
String xmlPreamble="";
String request = xmlPreamble+"GetVersionn";
System.out.println("Request: "+request+"n");
System.out.println("Response:");
ps.print(request);
BufferedReader br = new BufferedReader(new InputStreamReader(sock.getInputStream()));
String line;
int c;
long milliseconds=5000;
long endTime = System.currentTimeMillis()+milliseconds;
c=br.read();
while (System.currentTimeMillis()=0) {
System.out.print((char)c);
c=br.read();
}
br.close();
ps.close();
sock.close();
} catch (Exception e) {
System.out.println(e);
}
}