Thanks! I added selector.wait(), and now it works. But there's a problem!
I call this code every frame, and now it's blocking input. What can I do?
edit:
I removed selector.wait() and the check for selector.isReady() completely, and then set the client as non-blocking, and it seems to work!
Please tell me if what I'm doing is bad, lol