Does TCP/UDP protocol always send or receive file packets sequentially? Would it possible to make a choice which data packets will be sent first using sockets API?
Neither TCP nor UDP can guarantee packets arrive at their destination in sequence because they both use IP packets, and IP doesn't do any sequencing.
With UDP, there are two separate issues. One is the order of the packets that comprise a single datagram. You can't control this, and every implementation I know of will send them in order.
However, you can send your datagrams in whatever order you want. The individual fragments that comprise a datagram will be re-ordered by the receiver to reconstruct the original datagram. Datagrams received out of order (not in the order they were sent) will be passed to the application in the order they were received. A datagram is considered received when the last fragment required to re-construct it is received. Datagrams will be passed to the application as they are completed, regardless of the order they were sent.
With TCP, the implementation controls the formation of packets. You can't really control it at all. Every implementation I know of will send them in order. They are required to re-order them if they are received out of order.