users@glassfish.java.net

How to create a SocketServer?

From: <glassfish_at_javadesktop.org>
Date: Sun, 06 Jun 2010 05:15:46 PDT

I need to create a socket server to listen to port messages from inside of Glassfish.
If I write something simple like the code below, it freezes Glassfish during the deployment of the app.
What is the safe way to implement this functionality?

@Singleton
@Startup
public class MySocketServer {
    ServerSocket serverSocket = null;
    @PostConstruct
    private void init() {
        try {
            serverSocket = new ServerSocket(SOCKET_PORT);
        } catch (IOException ex) {
            System.err.println(ex.getMessage());
        }
//...
}
}
[Message sent by forum member 'denisz']

http://forums.java.net/jive/thread.jspa?messageID=472989