Java Socket Closes After Connection?
<p>Why does this port/socket close once a connection has been made by a client?</p>

<pre><code>package app;

import java.io.*;
import java.net.*;

public class socketServer {

public static void main(String[] args) {
    int port = 3333;
    boolean socketBindedToPort = false;

    try {
        ServerSocket ServerSocketPort = new ServerSocket(port);
        System.out.println("SocketServer Set Up on Port: " + port);
        socketBindedToPort = true;

        if(socketBindedToPort == true) {
            Socket clientSocket = null;

            try {
                clientSocket = ServerSocketPort.accept();//This method blocks until a socket connection has been made to this port.
                System.out.println("Waiting for client connection on port:" + port);
                /** THE CLIENT HAS MADE A CONNECTION **/
                System.out.println("CLIENT IS CONENCTED");
            } 
            catch (IOException e) {
                System.out.println("Accept failed: " + port);
                System.exit(-1);
            }
        }
        else {
            System.out.println("Socket did not bind to the port:" + port);
        }
    }
    catch(IOException e) {
        System.out.println("Could not listen on port: " + port);
        System.exit(-1);
    }



}


}
</code></pre>
