Reputation: 68
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?
Upvotes: 0
Views: 1226
Reputation: 310998
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.
Upvotes: 2