Suppose that I want to send and receive data through a tun
device.
I found the answer https://stackoverflow.com/a/35735842/6655884 where it opens /dev/net/tun
as if it were a file and reads from it. However, what if I want to send a packet to it? If I simply write
to it, then I'm gonna get the packet back when I read
from it, or I migth get lucky and read after the packet was sent.
How it works? Does /dev/net/tun
consumes what I write and not give it back when I read? Does it have knowledge of what is sent and received? I imagine it works like a file so whatever I write I get back when I read.