If I were to send a packet from one computer to another computer, directly connected via one ethernet cable, is it quicker to constantly poll on the receiving computer with UDP, or use Java RMI for the sender to "give" the packet to the receiving computer?
I was unaware if there was any performance variation?
It is generally faster to do UDP, as there is no additional acknowledgement overhead on the transmission, as there is no need to bother with receipt acknowledgements.
With TCP, there is an acknowledgement transmitted back to the source of the data. Full duplex communications can make the transmission of this acknowledgement occur without disrupting the incoming data stream; however, you do have to wait some amount of time for that acknowledgement to return the the sender, and that sender to process it.
While both computers are assumed to be fast enough to handle the data stream processing, in the real world computers might find themselves doing multiple tasks which could interrupt ability to handle network traffic at line speeds. In such a scenario, if the transmitting computer cannot receive the acknowledgements quickly enough (or the receiving computer cannot transmit them fast enough) then you may exhaust your window of unacknowledged packets, which would result in the transmitting computer halting transmission until it determined that either what was transmitted would need re-transmission or was received.
But UDP is no bed of roses, as it's solution to not acknowledging receipt is to allow any packet to disappear without notice at any time. As such, it is ideal for data that doesn't need to be transmitted completely (live voice, if it's dropped it is more important to start with the "now" packet than collect them all), or for data where the retransmission is managed by more efficient application-specific algorithms.