digitalmars.D.learn - Where is "open" in "core.sys.linux.unistd"?
- rempas (2/2) Jul 09 2021 The file can be found quickly
- rikki cattermole (8/13) Jul 09 2021 This is easily explained.
- rempas (2/12) Jul 09 2021 Thanks man, have a nice day
- Steven Schveighoffer (9/14) Jul 09 2021 Because file descriptors are created in different ways.
- Dennis (6/8) Jul 09 2021 For sockets you'd typically use `recv` and `send` instead or
- rempas (2/10) Jul 09 2021 That's very important! Thanks a lot for the info!
- Steven Schveighoffer (10/18) Jul 09 2021 I typically only use `send` and `recv` for for connectionless sockets.
- rempas (5/17) Jul 09 2021 If I tell you that I searched "fnctl" in the repo and didn't find
- =?UTF-8?Q?Ali_=c3=87ehreli?= (5/6) Jul 09 2021 Yes, the typo should be obvious to the non-dyslexic among us. :)
- rempas (6/12) Jul 09 2021 Lol, I'm not dyslexic (or at least I haven't find out) but still
The file can be found quickly [here](https://github.com/dlang/druntime/blob/master/src/core sys/posix/unistd.d) or in your system if you want. Now the question is, why isn't there an "open" function for the equivalent system call? "close", "write", "read" etc. all exist. Anyone knows what's going on with open?
Jul 09 2021
On 10/07/2021 2:51 AM, rempas wrote:The file can be found quickly [here](https://github.com/dlang/druntime/blob/master/src/core sys/posix/unistd.d) or in your system if you want. Now the question is, why isn't there an "open" function for the equivalent system call? "close", "write", "read" etc. all exist. Anyone knows what's going on with open?This is easily explained. open is not declared to be defined in unist.h[0] You may be wanting fopen from stdio.h[1] Or open from fcntl.h[2] [0] https://man7.org/linux/man-pages/man0/unistd.h.0p.html [1] https://man7.org/linux/man-pages/man0/stdio.h.0p.html [2] https://man7.org/linux/man-pages/man0/fcntl.h.0p.html
Jul 09 2021
On Friday, 9 July 2021 at 15:04:32 UTC, rikki cattermole wrote:On 10/07/2021 2:51 AM, rempas wrote:Thanks man, have a nice dayThe file can be found quickly [here](https://github.com/dlang/druntime/blob/master/src/core sys/posix/unistd.d) or in your system if you want. Now the question is, why isn't there an "open" function for the equivalent system call? "close", "write", "read" etc. all exist. Anyone knows what's going on with open?This is easily explained. open is not declared to be defined in unist.h[0] You may be wanting fopen from stdio.h[1] Or open from fcntl.h[2] [0] https://man7.org/linux/man-pages/man0/unistd.h.0p.html [1] https://man7.org/linux/man-pages/man0/stdio.h.0p.html [2] https://man7.org/linux/man-pages/man0/fcntl.h.0p.html
Jul 09 2021
On 7/9/21 10:51 AM, rempas wrote:The file can be found quickly [here](https://github.com/dlang/druntime/blob/master/src/core sys/posix/unistd.d) or in your system if you want. Now the question is, why isn't there an "open" function for the equivalent system call? "close", "write", "read" etc. all exist. Anyone knows what's going on with open?Because file descriptors are created in different ways. For example, `open` exists for files [here](https://github.com/dlang/druntime/blob/master/src/core/sys/posix/fcntl.d) But opening a socket is done via the `socket` system call [here](https://github.com/dlang/druntime/blob/master/src/core/sys/posix/sys/socket.d) They don't take the same arguments (nor should they). But reading/writing, closing these file descriptors is always the same. -Steve
Jul 09 2021
On Friday, 9 July 2021 at 15:11:38 UTC, Steven Schveighoffer wrote:But reading/writing, closing these file descriptors is always the same.For sockets you'd typically use `recv` and `send` instead or `read` and `write` because the former give extra options and the latter don't work on Windows. But yeah, on Linux `read` and `write` should work universally among file descriptors.
Jul 09 2021
On Friday, 9 July 2021 at 15:31:50 UTC, Dennis wrote:On Friday, 9 July 2021 at 15:11:38 UTC, Steven Schveighoffer wrote:That's very important! Thanks a lot for the info!But reading/writing, closing these file descriptors is always the same.For sockets you'd typically use `recv` and `send` instead or `read` and `write` because the former give extra options and the latter don't work on Windows. But yeah, on Linux `read` and `write` should work universally among file descriptors.
Jul 09 2021
On 7/9/21 11:31 AM, Dennis wrote:On Friday, 9 July 2021 at 15:11:38 UTC, Steven Schveighoffer wrote:I typically only use `send` and `recv` for for connectionless sockets. For TCP sockets, it's generally `read` and `write` for me (and it works fine). Windows is a different story, they have different i/o routines for system calls (yes, there's the shims for Posix file descriptors, but I wouldn't use those anyway). The larger point is that the reason `read`/`write` are separate from descriptor creation is because they are universal, while creation is not. -SteveBut reading/writing, closing these file descriptors is always the same.For sockets you'd typically use `recv` and `send` instead or `read` and `write` because the former give extra options and the latter don't work on Windows. But yeah, on Linux `read` and `write` should work universally among file descriptors.
Jul 09 2021
On Friday, 9 July 2021 at 15:11:38 UTC, Steven Schveighoffer wrote:On 7/9/21 10:51 AM, rempas wrote:If I tell you that I searched "fnctl" in the repo and didn't find anything will you believe me? Probably made a typo idk... Anyway thanks a lot your help and I wish you to have an amazing day!The file can be found quickly [here](https://github.com/dlang/druntime/blob/master/src/core sys/posix/unistd.d) or in your system if you want. Now the question is, why isn't there an "open" function for the equivalent system call? "close", "write", "read" etc. all exist. Anyone knows what's going on with open?Because file descriptors are created in different ways. For example, `open` exists for files [here](https://github.com/dlang/druntime/blob/master/src/core/sys/posix/fcntl.d) But opening a socket is done via the `socket` system call [here](https://github.com/dlang/druntime/blob/master/src/core/sys/posix/sys/socket.d) They don't take the same arguments (nor should they). But reading/writing, closing these file descriptors is always the same. -Steve
Jul 09 2021
On 7/9/21 8:31 AM, rempas wrote:I searched "fnctl" in the repo [...] Probably made a typoYes, the typo should be obvious to the non-dyslexic among us. :) fnctl <-- wrong fcntl <-- correct Ali
Jul 09 2021
On Friday, 9 July 2021 at 15:37:41 UTC, Ali Çehreli wrote:On 7/9/21 8:31 AM, rempas wrote:Lol, I'm not dyslexic (or at least I haven't find out) but still some times I just miss those small details. Its probably that in my mind, I never really noticed how it's typed in the first place. I thought "fn" then "ctl" for "control" so "function control" or something idk.... Anyway yeah nice catch ;)I searched "fnctl" in the repo [...] Probably made a typoYes, the typo should be obvious to the non-dyslexic among us. :) fnctl <-- wrong fcntl <-- correct Ali
Jul 09 2021