Popular Posts
javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... Close window without confirm (I.E only) window.opener=null; window.open('','_self'); window.close(); focus on validating function focusOnInvalidControl() {     for (var i = 0; i < Page_Validators.length; i++) {         if (!Page_Validators[i].isvalid) {     ...
Stats
Detect another program running status by using socket
import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.SocketException;
import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

public class MyFrame extends JFrame {

    private ServerSocket ss;

    public MyFrame() {

        try {
            // create a new socket and bind it to listen
            ss = new ServerSocket();
            ss.bind(new InetSocketAddress(100));
        } catch (SocketException e) {
            // if this socket is in using, presume the program is running
            JOptionPane.showMessageDialog(this, "Application already in running.");
            System.exit(1);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Application encountered some problem.");
            System.exit(1);
        }
        this.getContentPane().add(new JLabel("Hello world!"));
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(300, 300);
        this.setLocation(300, 300);
        this.setVisible(true);
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        new MyFrame();
    }

}