I have to create an application having a GUI. my application has to work as a server. When it starts, it has to accept all the incoming connection and write the output in a JTextArea. my problem is where I have to create the ServerSocket ss = new ServerSocket(port_number)
and the method ss.accept
in the way I can accept connections. I tried to create in the main constructor of my gui but being ServerSocket
anI/O
request the gui stucks.some idea to resolve the solution?
I create in the constructor of my GUI:
SwingUtilities.invokeLater(new Runnable(){public void run(){connection();}});
where connection()
is the method where I create the serversocket and accepts call