I am currently developing a file sharing application for a LAN. I can't decide if I am going to use TCP to tranfer the data between the computers or UDP. Another issue is that do I need create a method that is going to split large files into smaller? I know that UDP packets are only capable of transfering small amount of data. But I am wondering if there is any java method in the i/o does that for u.
TCP guarantees delivery of data and also guarantees that packets will be delivered in the same order in which they were sent. UDP on the other hand is an unreliable protocol. There is no guarantee that the datagram will be delivered to the destination host (although loss on a LAN is probably close to 0). The datagrams can also be delivered in an incorrect order. You can also receive the same packet twice. If you for some reason decide to use UDP, your application must be prepared to handle all those situations: missing datagram, duplicate datagram or datagram in the incorrect order. So unless we're talking broadcasting of video, audio etc where it's more important that the packet arrives on time then at all, you're better off using TCP.