I'm going to open a tun/tap file descriptor with f = os.open("/dev/net/tun", 'r+w')
it says you should choose only one option which are create
append
read
write
. But i need to be able to read and write from/into it. so i had to add buffering=0
, Now it works with read and write . But the speed of reading and writing of the tun is slow. I think it is related to buffering that i set it to 0
I want to know that is the speed of reading and writing related to buffering?
What i have to do to be able to have the tun opened with read and write ability without setting buffering to 0?
Asked
Active
Viewed 223 times
1

amir ghorbani
- 123
- 2
- 3
- 10
-
1Opening with `write` or `append` means you can also read. Buffering is not required. – pythomatic Jul 24 '19 at 13:38
-
From https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files: "`r+` opens the file for both reading and writing". Did you try that? – StardustGogeta Jul 24 '19 at 13:42
-
Possible duplicate of https://stackoverflow.com/questions/1466000/python-open-built-in-function-difference-between-modes-a-a-w-w-and-r – StardustGogeta Jul 24 '19 at 13:45
-
i tried both `r+` and `w` for reading and writing but not worked – amir ghorbani Jul 24 '19 at 14:04
-
when i use `r+` or `w+` says `io.UnsupportedOperation: File or stream is not seekable.` – amir ghorbani Jul 24 '19 at 14:08
-
i think what you guys saying is about files not tun/tap – amir ghorbani Jul 24 '19 at 14:18