AI-powered
podcast player
Listen to all your favourite podcasts with AI-powered features
TCP vs UDP - What's the Difference?
With TCP, like you know, your messages are getting there eventually. But with UDP, that's very much not the case. So for instance, we talked about reading data from a TCP connection in Go, you create a byte slice of a certain size and you will keep reading data into that until it's full or there's no more data to read. With UDP, it's different. If I send you four separate UDP packets, and they're sitting in your receive buffer, if you're using net.con, and you read, even if the byte slice you've allocated is large enough to hold all four of those messages, every invocation of read only returns one message at a time