37 lines
922 B
Java
37 lines
922 B
Java
package de.ctdo.crashtest;
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.DataOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.InputStreamReader;
|
|
import java.net.Socket;
|
|
|
|
public class LampelClient {
|
|
|
|
private static final int ECMD_TCP_PORT = 2701;
|
|
private static final String LAMPEL_HOST = "lampel.ctdo.de";
|
|
|
|
|
|
public void sendCommand(String command) {
|
|
|
|
try {
|
|
Socket client = new Socket(LAMPEL_HOST, ECMD_TCP_PORT);
|
|
client.setSoTimeout(800);
|
|
|
|
|
|
DataOutputStream outToServer = new DataOutputStream(client.getOutputStream());
|
|
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(client.getInputStream()));
|
|
|
|
|
|
outToServer.writeBytes(command + '\n');
|
|
|
|
String result = inFromServer.readLine();
|
|
|
|
client.close();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
}
|
|
}
|