Senior
Why is it fundamentally important to build authorization over TCP rather than UDP? What would be the problem if you wrote authorization on UDP?
sobes.tech AI
Answer from AI
TCP is a connection-oriented protocol with guaranteed delivery, which is critical for authorization because:
- Reliability: TCP guarantees that all packets will be delivered and in the correct order. This is important for transmitting authorization data to avoid losing or mixing messages.
- Session establishment: TCP establishes a connection, allowing to maintain state between the client and server, which is necessary for authorization and authentication.
If authorization were implemented over UDP:
- Packets could be lost or arrive out of order, leading to errors in the authorization process.
- The lack of connection establishment complicates session state tracking.
- Mechanisms for acknowledgment and retransmission would need to be implemented manually, which complicates the process and increases the likelihood of errors.
Thus, using TCP for authorization ensures reliable and secure data exchange, which cannot be guaranteed when using UDP.