Created
June 14, 2017 16:22
-
-
Save flawnn/4c463afcf434b397466b952e7b563e10 to your computer and use it in GitHub Desktop.
Serverside
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 ); | |
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