What is the best way to handle WebSocket requests using ServerSocket?

Viewed 14

In Java, I am attempting to create a WebSocket server using the ServerSocket class. Unfortunately, I encountered a problem where the only way I could've set up the server was to send an HTTP request that contains the proper data to upgrade the connection to WebSocket. Does the ServerSocket class have to capability to accept ws:// connections (and I am making a mistake somewhere), or do I have to continue manually upgraded the request?

//This block only shows the relevant code
ServerSocket serverSocket = new ServerSocket(8080);
Socket socket = serverSocket.accept();
System.out.println("Client connected");

"Client connected" is written to console when using http://, but not ws://.

0 Answers
Related