74 lines
2.0 KiB
Java
74 lines
2.0 KiB
Java
/*
|
|
* To change this license header, choose License Headers in Project Properties.
|
|
* To change this template file, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
package client;
|
|
|
|
import java.io.*;
|
|
import java.net.*;
|
|
|
|
/**
|
|
* Hauptklasse des Clients
|
|
* @version 0.0.1
|
|
* @author eichehome
|
|
*/
|
|
public class MainClient {
|
|
|
|
static Socket server = null;
|
|
static PrintWriter pr = null;
|
|
static BufferedReader bf = null;
|
|
static InputStreamReader in = null;
|
|
|
|
/**
|
|
* @param args the command line arguments
|
|
*/
|
|
public static void main(String[] args) {
|
|
try {
|
|
server = new Socket("localhost", 1236);
|
|
|
|
pr = new PrintWriter(server.getOutputStream());
|
|
pr.println("is it working?");
|
|
pr.flush();
|
|
|
|
in = new InputStreamReader(server.getInputStream());
|
|
bf = new BufferedReader(in);
|
|
String str = bf.readLine();
|
|
System.out.println("server: " + str);
|
|
try {
|
|
System.out.println("Sleepin for 5 seconds");
|
|
Thread.sleep(10000);
|
|
} catch (InterruptedException e) {
|
|
System.out.println("Thread is interrupted");
|
|
}
|
|
} catch (IOException e) {
|
|
System.err.println("Fehler: " + e);
|
|
} finally {
|
|
if (in != null) {
|
|
try {
|
|
in.close();
|
|
} catch (IOException e) {
|
|
System.err.println("Fehler: " + e);
|
|
}
|
|
}
|
|
if (bf != null) {
|
|
try {
|
|
bf.close();
|
|
} catch (IOException e) {
|
|
System.err.println("Fehler: " + e);
|
|
}
|
|
}
|
|
if (pr != null) {
|
|
pr.close();
|
|
}
|
|
if (server != null) {
|
|
try {
|
|
server.close();
|
|
} catch (IOException e) {
|
|
System.err.println("Fehler: " + e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|