C
Chris Berg
My client/server application works with sockets, one for each user,
the sockets remain open for the entire session. Each client has a
separate thread on the server. A traditional design, but limited in
the max. number of conccurrent clients.
I think using non-blocking NIO should be able to greatly enhance the
system. However, there are two obstacles:
1) I need to re-write the thread code, especially the logic for
creation/destruction of a session, as there is now no thread that
governs the state of a user. This involves creating a state-vector and
a state-machine. But I can see a way through that.
2) I need to understand NIO in more detail. Looking at Sun's examples,
it looks quite a bit more complicates that old IO. Specifically, my
protocol has telegrams whose size can only be determined at run-time,
an that are in principle limitless. As I understand the NIO socket
handling, this complicates matters quite a bit as it uses fixed-size
buffers, but I may have misunderstood something.
So, my question:
Does anyone know of an example somewhere on the web that can be used
as a pattern?
Chris
the sockets remain open for the entire session. Each client has a
separate thread on the server. A traditional design, but limited in
the max. number of conccurrent clients.
I think using non-blocking NIO should be able to greatly enhance the
system. However, there are two obstacles:
1) I need to re-write the thread code, especially the logic for
creation/destruction of a session, as there is now no thread that
governs the state of a user. This involves creating a state-vector and
a state-machine. But I can see a way through that.
2) I need to understand NIO in more detail. Looking at Sun's examples,
it looks quite a bit more complicates that old IO. Specifically, my
protocol has telegrams whose size can only be determined at run-time,
an that are in principle limitless. As I understand the NIO socket
handling, this complicates matters quite a bit as it uses fixed-size
buffers, but I may have misunderstood something.
So, my question:
Does anyone know of an example somewhere on the web that can be used
as a pattern?
Chris