Does Linux kernel create a file for an Internet domain socket? [duplicate]












3















This question already has an answer here:




  • Is there a file for each socket?

    3 answers




The Linux kernel creates a file for a Unix domain socket bound to a pathname.



Does the Linux kernel create a file for an Internet domain socket?










share|improve this question















marked as duplicate by Sergiy Kolodyazhnyy, RalfFriedl, Isaac, Stephen Harris, Mr Shunz yesterday


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




















    3















    This question already has an answer here:




    • Is there a file for each socket?

      3 answers




    The Linux kernel creates a file for a Unix domain socket bound to a pathname.



    Does the Linux kernel create a file for an Internet domain socket?










    share|improve this question















    marked as duplicate by Sergiy Kolodyazhnyy, RalfFriedl, Isaac, Stephen Harris, Mr Shunz yesterday


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















      3












      3








      3








      This question already has an answer here:




      • Is there a file for each socket?

        3 answers




      The Linux kernel creates a file for a Unix domain socket bound to a pathname.



      Does the Linux kernel create a file for an Internet domain socket?










      share|improve this question
















      This question already has an answer here:




      • Is there a file for each socket?

        3 answers




      The Linux kernel creates a file for a Unix domain socket bound to a pathname.



      Does the Linux kernel create a file for an Internet domain socket?





      This question already has an answer here:




      • Is there a file for each socket?

        3 answers








      linux socket






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago









      Peter Mortensen

      88758




      88758










      asked Jan 6 at 2:07









      TimTim

      26.3k74246455




      26.3k74246455




      marked as duplicate by Sergiy Kolodyazhnyy, RalfFriedl, Isaac, Stephen Harris, Mr Shunz yesterday


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Sergiy Kolodyazhnyy, RalfFriedl, Isaac, Stephen Harris, Mr Shunz yesterday


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
























          2 Answers
          2






          active

          oldest

          votes


















          5














          No, not in the sense of a file on hard-drive or other block device.



          If you look at socket.c in Linux source code, you will see that it creates an inode for sockets, however data is in sockfs filesystem, which is a virtual filesystem within kernel itself, and space is allocated via kmalloc type of function. In that sense, sockets are anonymous files residing in memory.



          This brings back to the concept of "everything is a file in Unix", which is a design pattern that focuses on having common utilities to perform same functions similar to files on real physical media. As Linus Torvalds stated:




          The whole point with "everything is a file" is not that you have some random filename (indeed, sockets and pipes show that "file" and "filename" have nothing to do with each other), but the fact that you can use common tools to operate on different things.




          Thus sockets have inode to have file-like access, but not present on physical filesystem.



          However, note, there exist Unix domain sockets, which are IPC type of object intended for process networking, and do reside on disk filesystems.






          share|improve this answer

















          • 1




            @Tim I'd say yes. If you look at this they've referenced lsof output: "0xffff8803e256d9c0. That number is actually the address of the relevant in-kernel memory structure or type struct unix_sock". So there has to be an inode in kernel's virtual filesystem corresponding to that
            – Sergiy Kolodyazhnyy
            Jan 6 at 2:44






          • 1




            And according to Gilles's answer " Unix socket which is not in the filesystem namespace (it can be in the abstract namespace or unnamed)"
            – Sergiy Kolodyazhnyy
            Jan 6 at 2:47



















          1















          The Linux kernel creates a file for a Unix domain socket bound to a pathname.




          OK.




          Does the Linux kernel create a file for an Internet domain socket?




          No. Binding a socket to an IP address+port does not synthesize a pathname. It does not create a file somewhere you can see.



          bind() on a AF_INET / AF_INET6 socket does not create any file on any physical filesystem. The bind() call will not generate a file on any of the builtin virtual filesystems. (Of course you can write your own FUSE filesystem, which mimics netstat -46 in some way, so that it creates a new file).






          share|improve this answer




























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5














            No, not in the sense of a file on hard-drive or other block device.



            If you look at socket.c in Linux source code, you will see that it creates an inode for sockets, however data is in sockfs filesystem, which is a virtual filesystem within kernel itself, and space is allocated via kmalloc type of function. In that sense, sockets are anonymous files residing in memory.



            This brings back to the concept of "everything is a file in Unix", which is a design pattern that focuses on having common utilities to perform same functions similar to files on real physical media. As Linus Torvalds stated:




            The whole point with "everything is a file" is not that you have some random filename (indeed, sockets and pipes show that "file" and "filename" have nothing to do with each other), but the fact that you can use common tools to operate on different things.




            Thus sockets have inode to have file-like access, but not present on physical filesystem.



            However, note, there exist Unix domain sockets, which are IPC type of object intended for process networking, and do reside on disk filesystems.






            share|improve this answer

















            • 1




              @Tim I'd say yes. If you look at this they've referenced lsof output: "0xffff8803e256d9c0. That number is actually the address of the relevant in-kernel memory structure or type struct unix_sock". So there has to be an inode in kernel's virtual filesystem corresponding to that
              – Sergiy Kolodyazhnyy
              Jan 6 at 2:44






            • 1




              And according to Gilles's answer " Unix socket which is not in the filesystem namespace (it can be in the abstract namespace or unnamed)"
              – Sergiy Kolodyazhnyy
              Jan 6 at 2:47
















            5














            No, not in the sense of a file on hard-drive or other block device.



            If you look at socket.c in Linux source code, you will see that it creates an inode for sockets, however data is in sockfs filesystem, which is a virtual filesystem within kernel itself, and space is allocated via kmalloc type of function. In that sense, sockets are anonymous files residing in memory.



            This brings back to the concept of "everything is a file in Unix", which is a design pattern that focuses on having common utilities to perform same functions similar to files on real physical media. As Linus Torvalds stated:




            The whole point with "everything is a file" is not that you have some random filename (indeed, sockets and pipes show that "file" and "filename" have nothing to do with each other), but the fact that you can use common tools to operate on different things.




            Thus sockets have inode to have file-like access, but not present on physical filesystem.



            However, note, there exist Unix domain sockets, which are IPC type of object intended for process networking, and do reside on disk filesystems.






            share|improve this answer

















            • 1




              @Tim I'd say yes. If you look at this they've referenced lsof output: "0xffff8803e256d9c0. That number is actually the address of the relevant in-kernel memory structure or type struct unix_sock". So there has to be an inode in kernel's virtual filesystem corresponding to that
              – Sergiy Kolodyazhnyy
              Jan 6 at 2:44






            • 1




              And according to Gilles's answer " Unix socket which is not in the filesystem namespace (it can be in the abstract namespace or unnamed)"
              – Sergiy Kolodyazhnyy
              Jan 6 at 2:47














            5












            5








            5






            No, not in the sense of a file on hard-drive or other block device.



            If you look at socket.c in Linux source code, you will see that it creates an inode for sockets, however data is in sockfs filesystem, which is a virtual filesystem within kernel itself, and space is allocated via kmalloc type of function. In that sense, sockets are anonymous files residing in memory.



            This brings back to the concept of "everything is a file in Unix", which is a design pattern that focuses on having common utilities to perform same functions similar to files on real physical media. As Linus Torvalds stated:




            The whole point with "everything is a file" is not that you have some random filename (indeed, sockets and pipes show that "file" and "filename" have nothing to do with each other), but the fact that you can use common tools to operate on different things.




            Thus sockets have inode to have file-like access, but not present on physical filesystem.



            However, note, there exist Unix domain sockets, which are IPC type of object intended for process networking, and do reside on disk filesystems.






            share|improve this answer












            No, not in the sense of a file on hard-drive or other block device.



            If you look at socket.c in Linux source code, you will see that it creates an inode for sockets, however data is in sockfs filesystem, which is a virtual filesystem within kernel itself, and space is allocated via kmalloc type of function. In that sense, sockets are anonymous files residing in memory.



            This brings back to the concept of "everything is a file in Unix", which is a design pattern that focuses on having common utilities to perform same functions similar to files on real physical media. As Linus Torvalds stated:




            The whole point with "everything is a file" is not that you have some random filename (indeed, sockets and pipes show that "file" and "filename" have nothing to do with each other), but the fact that you can use common tools to operate on different things.




            Thus sockets have inode to have file-like access, but not present on physical filesystem.



            However, note, there exist Unix domain sockets, which are IPC type of object intended for process networking, and do reside on disk filesystems.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 6 at 2:30









            Sergiy KolodyazhnyySergiy Kolodyazhnyy

            8,49312254




            8,49312254








            • 1




              @Tim I'd say yes. If you look at this they've referenced lsof output: "0xffff8803e256d9c0. That number is actually the address of the relevant in-kernel memory structure or type struct unix_sock". So there has to be an inode in kernel's virtual filesystem corresponding to that
              – Sergiy Kolodyazhnyy
              Jan 6 at 2:44






            • 1




              And according to Gilles's answer " Unix socket which is not in the filesystem namespace (it can be in the abstract namespace or unnamed)"
              – Sergiy Kolodyazhnyy
              Jan 6 at 2:47














            • 1




              @Tim I'd say yes. If you look at this they've referenced lsof output: "0xffff8803e256d9c0. That number is actually the address of the relevant in-kernel memory structure or type struct unix_sock". So there has to be an inode in kernel's virtual filesystem corresponding to that
              – Sergiy Kolodyazhnyy
              Jan 6 at 2:44






            • 1




              And according to Gilles's answer " Unix socket which is not in the filesystem namespace (it can be in the abstract namespace or unnamed)"
              – Sergiy Kolodyazhnyy
              Jan 6 at 2:47








            1




            1




            @Tim I'd say yes. If you look at this they've referenced lsof output: "0xffff8803e256d9c0. That number is actually the address of the relevant in-kernel memory structure or type struct unix_sock". So there has to be an inode in kernel's virtual filesystem corresponding to that
            – Sergiy Kolodyazhnyy
            Jan 6 at 2:44




            @Tim I'd say yes. If you look at this they've referenced lsof output: "0xffff8803e256d9c0. That number is actually the address of the relevant in-kernel memory structure or type struct unix_sock". So there has to be an inode in kernel's virtual filesystem corresponding to that
            – Sergiy Kolodyazhnyy
            Jan 6 at 2:44




            1




            1




            And according to Gilles's answer " Unix socket which is not in the filesystem namespace (it can be in the abstract namespace or unnamed)"
            – Sergiy Kolodyazhnyy
            Jan 6 at 2:47




            And according to Gilles's answer " Unix socket which is not in the filesystem namespace (it can be in the abstract namespace or unnamed)"
            – Sergiy Kolodyazhnyy
            Jan 6 at 2:47













            1















            The Linux kernel creates a file for a Unix domain socket bound to a pathname.




            OK.




            Does the Linux kernel create a file for an Internet domain socket?




            No. Binding a socket to an IP address+port does not synthesize a pathname. It does not create a file somewhere you can see.



            bind() on a AF_INET / AF_INET6 socket does not create any file on any physical filesystem. The bind() call will not generate a file on any of the builtin virtual filesystems. (Of course you can write your own FUSE filesystem, which mimics netstat -46 in some way, so that it creates a new file).






            share|improve this answer


























              1















              The Linux kernel creates a file for a Unix domain socket bound to a pathname.




              OK.




              Does the Linux kernel create a file for an Internet domain socket?




              No. Binding a socket to an IP address+port does not synthesize a pathname. It does not create a file somewhere you can see.



              bind() on a AF_INET / AF_INET6 socket does not create any file on any physical filesystem. The bind() call will not generate a file on any of the builtin virtual filesystems. (Of course you can write your own FUSE filesystem, which mimics netstat -46 in some way, so that it creates a new file).






              share|improve this answer
























                1












                1








                1







                The Linux kernel creates a file for a Unix domain socket bound to a pathname.




                OK.




                Does the Linux kernel create a file for an Internet domain socket?




                No. Binding a socket to an IP address+port does not synthesize a pathname. It does not create a file somewhere you can see.



                bind() on a AF_INET / AF_INET6 socket does not create any file on any physical filesystem. The bind() call will not generate a file on any of the builtin virtual filesystems. (Of course you can write your own FUSE filesystem, which mimics netstat -46 in some way, so that it creates a new file).






                share|improve this answer













                The Linux kernel creates a file for a Unix domain socket bound to a pathname.




                OK.




                Does the Linux kernel create a file for an Internet domain socket?




                No. Binding a socket to an IP address+port does not synthesize a pathname. It does not create a file somewhere you can see.



                bind() on a AF_INET / AF_INET6 socket does not create any file on any physical filesystem. The bind() call will not generate a file on any of the builtin virtual filesystems. (Of course you can write your own FUSE filesystem, which mimics netstat -46 in some way, so that it creates a new file).







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 2 days ago









                sourcejedisourcejedi

                23.1k437102




                23.1k437102















                    Popular posts from this blog

                    If I really need a card on my start hand, how many mulligans make sense? [duplicate]

                    Alcedinidae

                    Can an atomic nucleus contain both particles and antiparticles? [duplicate]