Created
June 14, 2017 17:51
-
-
Save flawnn/7a812c8b5ca63f512efb040903e25f1c to your computer and use it in GitHub Desktop.
Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.flawn; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import java.net.ServerSocket; | |
import java.net.Socket; | |
import java.util.Scanner; | |
public class Main { | |
private static void handleConnection( Socket client ) throws IOException | |
{ | |
Scanner in = new Scanner( client.getInputStream() ); | |
PrintWriter out = new PrintWriter( client.getOutputStream(), true ); | |
//Schickt eine Nachricht wenn verbunden wurde, die kommt aber komischerweise nie | |
System.out.println("VErbindung izz da"); | |
out.println("Es geht lul"); | |
} | |
public static void main( String[] args ) throws IOException | |
{ | |
ServerSocket server = new ServerSocket( 3141 ); | |
while ( true ) | |
{ | |
Socket client = null; | |
try | |
{ | |
client = server.accept(); | |
handleConnection ( client ); | |
} | |
catch ( IOException e ) { | |
e.printStackTrace(); | |
} | |
finally { | |
if ( client != null ) | |
try { client.close(); } catch ( IOException e ) { } | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment