Scalability will probably drive your choice of package. Java.net will require one thread per socket. Coding it will be significantly easier.Java.
Nio is much more efficient, but can be hairy to code around.
Scalability will probably drive your choice of package. Java.net will require one thread per socket. Coding it will be significantly easier.Java.
Nio is much more efficient, but can be hairy to code around. I would ask yourself how many connections you expect to be handling. If it's relatively few (say.
1 With a modern 64-bit OS you can have hundreds of thousands of threads. – Tom Hawtin - tackline Nov 6 '08 at 16:03 3 Sure, but that's not necessarily the most scalable way to architect an application. – Jim Nelson Nov 6 '08 at 22:12 1 But a socket is much more resource intensive than a thread... – Zombies Apr 14 '10 at 15:45 The question is not one of more sockets versus more threads.It's how many threads per socket.
– Jim Nelson Apr 23 '10 at 2:32.
Avoid NIO unless you have a good reason to use it. It's not much fun and may not be as beneficial as you would think. You may get better scalability once you are dealing with tens of thousands of connections, but at lower numbers you'll probably get better throughput with blocking IO.As always though, make your own measurements before committing to something you might regret.
Something else to consider is that if you want to use SSL, NIO makes it extremely painful.
Each remote server will have up to 8 connections, all from the same client (to control all the hardware, and separate TX/RX sockets). The single client will want to connect to several servers at once, though. Instead of putting each server on different ports, is it possible to use channel selectors on the client side, or is it better to go multi-threaded io on the client side of things and configure the servers differently?
Really, I just want to be able to send commands and receive telemetry from the hardware, and not have to make up some application layer protocol to do it.
The number of connections you're talking about tells me you should use java.net. Really, there's no reason to complexify your task with non-blocking I/O. (Unless your remote systems are underpowered, but then why are you using Java on them?) Take a look at Apache's XML-RPC package.
It's easy to use, completely hides the network stuff from you, and works over good ol' HTTP. No need to worry about protocol issues ... it'll all look like method calls to you, on both ends.
. – drhorrible Nov 7 '08 at 4:16 It's a plain library and should work in SE and EE. Like another commentator mentioned, it does have its scalability issues.
But for the 98% case, I think it's pretty solid. – Jim Nelson Nov 7 '08 at 8:00.
Given the small number of connections involved, java.net sounds like the right solution. Other posters talked about using XML-RPC. This is a good choice if the volumes of data being shipped are small, however I have had bad experiences with XML-based protocols when writing inter-process communications that ship large amounts of data (e.g. Large request/responses, or frequent small amounts of data).
The cost of XML parsing is typically orders of magnitude higher than more optimised wire formats (e.g. ASN.1). For low volume control applications the simplicity of XML-RPC should outweigh the performance costs. For high volume data communications it may be better to use a more efficient wire protocol.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.