Skip to content

Instantly share code, notes, and snippets.

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