package buzzerproxy.bprot; import java.net.ServerSocket; import java.net.Socket; import buzzerproxy.handler.ExceptionHandler; import buzzerproxy.handler.QuestionInterface; /** * * @author M. Friedeboldt */ public class ByteProtServer extends Thread { private int port; private ExceptionHandler handler; private SessionManager sessionManager; private QuestionInterface questionInterface; /** * * @param port * @throws Exception */ public ByteProtServer(int port, QuestionInterface questionInterface, ExceptionHandler handler) { this.port = port; this.handler = handler; this.questionInterface = questionInterface; } @Override public void run() { try { // create Server ServerSocket socket = new ServerSocket( port ); /** * Wo die IP Abspeichern, sodass diese für die Logs verarbeitet werden kann? * String clientIP = socket.getInetAddress().getHostAddress(); */ // Session Manager sessionManager = new SessionManager( questionInterface ); // Wait... while ( true ) { System.out.println( "wait for ...." ); Socket sock = socket.accept(); try { sock.setKeepAlive(true); // sock.setSoTimeout(timeout); sock.setTrafficClass(0x04); // reliablity sock.setTcpNoDelay(true); } catch (Exception x) { } System.out.println( "accept() ..." ); new ByteProtComm( sock, sessionManager ).start(); } } catch ( Exception e ) { handler.throwException( e ); } } }