Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

public class Main {
    public static void main(String[] args) throws Exception {
        ServerSocket server = new ServerSocket(8123);
        while (true) {
            Socket sock = server.accept();
            InetAddress addr = sock.getInetAddress();
            System.out.println("Connection made to " + addr.getHostName() + " (" + addr.getHostAddress() + ")");
            Thread.sleep(5000);
            sock.close();
        }
    }
}