Junior — Middle
Are there one-way communication channels in systems or protocols?
sobes.tech AI
Answer from AI
Yes, there are unidirectional communication channels in systems and protocols. These are channels through which data is transmitted only in one direction — from sender to receiver, without feedback.
An example is the UDP protocol, where the sender sends packets, but receipt or response is not guaranteed. Unidirectional channels are also often used in broadcasting systems, where information is transmitted to many recipients without feedback.
In Go language, unidirectional channels can be created using the keywords chan<- (for sending only) and <-chan (for receiving only):
var sendOnly chan<- int // channel for sending only
var receiveOnly <-chan int // channel for receiving only
This helps control the direction of data transfer between goroutines.