package com.github.noxan.aves.server;

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

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.setSoTimeout(1000);
	    server.bind(new InetSocketAddress(host, port));
	} catch (IOException e) {
	    e.printStackTrace();
	}
    }

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

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

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

@@ -190,16 +190,113 @@
 ption;%0A%0A
+import com.github.noxan.aves.net.Connection;%0Aimport com.github.noxan.aves.net.SocketConnection;%0A%0A
 public c
@@ -922,24 +922,86 @@
 r.accept();%0A
+%09%09Connection connection = new SocketConnection(this, socket);%0A
 %09    %7D catch

create connection for new connected clients