This might sound weird. I have created a game server based on a thread per socket structure (yes, only one thread per user; responses are sent to clients by worker threads). The thread that I spawn first authenticates the user and handles log-in, after that it only receives data and queues it up for processing. The authentication part is very critical and took a long time to implement, and would take as long to implement again, so I was thinking, after authentication's finished, can I convert the blocking socket that I have into a SocketChannel's socket so that a Selector can handle its messages in a non-blocking manner?
Asked
Active
Viewed 1,165 times
1 Answers
2
You can't. You have to start with a SocketChannel, then you can use the socket() from that in blocking mode, or the channel itself in either blocking or non-blocking mode.

user207421
- 305,947
- 44
- 307
- 483
-
What if using Socket.getChannel()? – aaron.chu Aug 03 '20 at 15:42