psykiatris / inspirations

This project is slowly being built into a multiplayer environment using JDK10.
MIT License
1 stars 0 forks source link

Using NIO and channels ... #5

Open psykiatris opened 5 years ago

psykiatris commented 5 years ago

I want to use the Channels classes to handle multiple clients with a server.

I apolgize for the addition/deletion of files, but trying to understand Channels (with selectors, binding, and all that). I created so many files and I've confused myself, so I'm starting over.

One response to a question on Stack Overflow mentioned to use channelN.socket().setReusable(true) for each N oruir ti binding.

Opening this issue to manage progress.

If ones are experienced in NIO and managing channels (thread or thresd-less) let me know. As I'm developing this project using JDK11 (and 12) I want to use the new APIs.

nikalsh commented 5 years ago

Hi psykiatris, I would like to help. By no means an expert but I'm interested in NIO. I have built a working multi-client single-threaded server (actually dual-threaded, one thread for accepting new connections and one thread for reading/writing to all connected clients) with NIO's channel, selector and buffer classes.

psykiatris commented 5 years ago

Great! We can help each other. I’ve dabbled in Java since 1.2 but got back into a few months ago so brushing up on the new changes since JDK 9. I appreciate the help.

psykiatris commented 5 years ago

Just a question: Whivh OS are you using? For me, I am usingbUbuntu 18.04.

The past week was stressful for me. My wife attempted to commit suicide. So, she was taken away. Lot of stuff on my mind. So, I can’t remember if I cleaned out my /listen and /talk folders. I might have, when I looked at your code, I had to change Protocol.

Anyway, thanks for the updates. I was really agonizing over which Channel class would work the best.

May I make any addition to your code, with comments?

nikalsh commented 5 years ago

I'm on Windows 7.

Oh, so sorry to hear :( I hope she gets better.

I still have the fork I made of your repo (before realizing you invited me as contributor :)) and there's no /listen or /talk folders there.

Of course, you can change the code as you see fit.

psykiatris commented 5 years ago

Yeah, I hope she gets better soon. As I’m legally blind, things are a little upside down right now.

Anyway, good job on the server code. I will work on a nil client for a bit.