Initzialer Commit mit dem aktuellen Stand
This commit is contained in:
parent
ba4867d4f5
commit
c50b9c4aff
14 changed files with 2291 additions and 0 deletions
73
src/client/MainClient.java
Normal file
73
src/client/MainClient.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue