简体   繁体   中英

Any java libs using SocketChannel client code?

I've looked at a number of open source java networking libs (jdbc drivers, apache commons net etc) and I've yet to find a library that makes usage of SocketChannel for other than simple use cases (V3 of mysql's jdbc connector used socketchannel but newer versions use jn.Socket).

I'm only interested in client code libraries. (libraries that connect, not listen).

FYI, I'm implementing an abstraction layer for java sockets (client only) and I need some use cases to make the SocketChannel work worthwhile. So far, any (client) libs I've seen seem to be going away from SocketChannels and back to java 1.0 Socket based implementations, probably because they're all interested in using SSL (not sure).

So, the real question is, should I bother supporting SocketChannel & co at all? (for client side libs since the platform does not support incoming connections anyway... yet.)

Similarly, I'm also interested in DatagramChannel. (same question, should I bother supporting this class?)

Any ideas where else I should be looking?

You use NIO when you think you're going to have thousands of connections, you want to economize on threads, you don't mind the considerable added complexity, and you think there will be a benefit. Most of the time one or more of these things isn't true so you don't. I doubt that I would ever use it for new code, more as a retrofit. For examples see Netty, Tomcat, Mina, ... There's an argument that says that select() was designed for processes, and now we have threads you don't really need it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM