Open nhatnd20 opened 4 years ago
First, beacuse NIO is single-thread socket managment, if you want to transport huge bits of data, it will block all other read and write event.
Second, SocketChannel Library used a byte-base protocol for automatic heartbeat and some file transport header, you can not access raw socket, so you can not implement some protocol by your self, createUnmanagedSocket can give you a raw connection. By the way, file transport is also depends on this feature by running on an independent thread to avoid blocking other connection.
NIO is designed to manage large numbers of connection, but these connection transport small bit of data and it doesn't transport all the time.
thanks for the clear explanation. But I see you have created a lot of new Thread(), it will affect the performance of the program ?
In SocketChannel, I use Thread Pool to run some code, it will reuse thread instead of create it. Some new Thread()
is pass the data to another thread to avoid blocking reading event from connection manage thread. It should affect some performance, so I scheduled to fully rewrite this library due to performance issue and some poorly expandability design.
Unfortunately, I don't have enough time to do these now.
I have planned to use listener design to improve the possibility for more protocol support and give more simplify data processing workflow.
Hi, I am new to socket programming, what is the purpose of Raw Socket? (createUnmanagedSocket method)