aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/xmpp/s2s/ConnectionListener.java
blob: f9b788c426981deb20df7e5120bc8cba7c96ef15 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.juick.xmpp.s2s;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Logger;

/**
 *
 * @author ugnich
 */
public class ConnectionListener implements Runnable {

    private static final Logger LOGGER = Logger.getLogger(ConnectionListener.class.getName());

    ExecutorService executorService = Executors.newCachedThreadPool();

    @Override
    public void run() {
        try {
            ServerSocket listener = new ServerSocket(5269);
            while (true) {
                Socket sock = listener.accept();
                ConnectionIn conn = new ConnectionIn(sock);
                XMPPComponent.addConnectionIn(conn);
                executorService.submit(conn);
            }
        } catch (IOException e) {
            LOGGER.info("IOException on socket listen: " + e.toString());
        }
    }
}