Sunday, July 8, 2001 11:55 AM
Can you be much more specific about what you want to know and why?
I'll risk offending you and give you the simple answer. If you already knew this, at least it'll give you a basis upon which you can clarify what it is you want to know.
TCP/IP is a persistent connection. I am not an expert in the "under-the-hood" implementation of TCP/IP, but I can tell you that the data delivery is "guaranteed." All this means is that you'll know for sure whether or not the data got there. If you send data and there is a delivery failure at any point, the OS will let the JVM know and you'll have the chance to resend the data. For large volumes of critical data, TCP/IP is necessary to ensure data integrity.
Because of all the implementation details necessary to guarantee delivery, TCP/IP is by nature much more "expensive" to use than UDP.
UDP is not guaranteed and it is not persistent. This means that once you send the data, the OS/JVM is probably not going to know whether or not the data was delivered successfully. Because there is less overhead, UDP is faster than TCP/IP.
In my experience, I find that many developers use UDP for the speed, and write their own messaging to monitor delivery and receipt. This is especially useful for non-critical applications like chat-rooms, where if
one sentence in a thousand gets lost, it's unlikely anybody's going to be fired for it.