How come, when I use ServerSocket.accept(), it stalls lines of code that should already be running? Here's my code: c2 = Container, jf2 = JFrame, t = timer, ssock = ServerSocket, sock = Socket.
The code gets run through, and doesnt get past sock = ssock.accept(). The weird thing is that the JFrame pops up ( .show() ), but the defaultCloseOperation() isnt set, and the timer isnt .start()'ed. t.isRunning() returns true, but the timer isnt triggering its actionEvents. i know the code is right because as soon as i comment out sock = ssock.accept(), everything works. What is .accept() doing that i dont understand?
This is my simple religion. There is no need for temples; no need for complicated philosophy. Our own brain, our own heart is our temple; the philosophy is kindness.<br />- Dalai Lama
ServerSocket.accept() blocks until a client requests a connection. You are probably running this code in the Swing event thread, invoking this method from an event handler or something of that nature, and paralizing any further events from the GUI. Try setting up your server socket in the main() method. It runs in a seperate thread.