package com.github.noxan.aves.server;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;

public class SocketServer implements Server, Runnable {
    private String host;
    private int port;

    private ServerSocket server;

    public SocketServer() {
	this.host = "0.0.0.0";
	this.port = 1666;
    }

    public SocketServer(String host, int port) {
	this.host = host;
	this.port = port;
    }

    @Override
    public void start() {
	try {
	    server = new ServerSocket();
	    server.bind(new InetSocketAddress(host, port));
	} catch (IOException e) {
	    e.printStackTrace();
	}
    }

    @Override
    public void run() {
	while (true) {
	    try {
		Socket socket = server.accept();
	    } catch (IOException e) {
		e.printStackTrace();
	    }
	}
    }

    @Override
    public String getHost() {
	return host;
    }

    @Override
    public int getPort() {
	return port;
    }
}

@@ -148,16 +148,56 @@
 .Socket;
+%0Aimport java.net.SocketTimeoutException;
 %0A%0Apublic
@@ -577,24 +577,56 @@
 erSocket();%0A
+%09    server.setSoTimeout(1000);%0A
 %09    server.
@@ -825,24 +825,66 @@
 r.accept();%0A
+%09    %7D catch (SocketTimeoutException e) %7B%0A
 %09    %7D catch

set socket timeout for socketserver and ignore socket timeout exceptions