Unix vs BSD vs TCP vs Internet sockets?










6















I am reading The Linux Programming Interface and it describes several different types of socket used on Linux:



  • Unix domain

  • Berkeley

  • TCP

  • Internet

One of the things the book said is that if you want to communicate between remote hosts, you couldn't use Unix domain sockets because they are for IPC on the same host. You have to use "Internet" sockets.



However, I am still a little confused how this relates with "TCP" sockets, Berkeley sockets and the other 2? What is their relationship? Why would you have an Internet socket as well as a TCP socket?



In short I am trying to understand all (have I missed any out?) the various different types of Unix sockets and under what circumstances I would use them?










share|improve this question




























    6















    I am reading The Linux Programming Interface and it describes several different types of socket used on Linux:



    • Unix domain

    • Berkeley

    • TCP

    • Internet

    One of the things the book said is that if you want to communicate between remote hosts, you couldn't use Unix domain sockets because they are for IPC on the same host. You have to use "Internet" sockets.



    However, I am still a little confused how this relates with "TCP" sockets, Berkeley sockets and the other 2? What is their relationship? Why would you have an Internet socket as well as a TCP socket?



    In short I am trying to understand all (have I missed any out?) the various different types of Unix sockets and under what circumstances I would use them?










    share|improve this question


























      6












      6








      6


      5






      I am reading The Linux Programming Interface and it describes several different types of socket used on Linux:



      • Unix domain

      • Berkeley

      • TCP

      • Internet

      One of the things the book said is that if you want to communicate between remote hosts, you couldn't use Unix domain sockets because they are for IPC on the same host. You have to use "Internet" sockets.



      However, I am still a little confused how this relates with "TCP" sockets, Berkeley sockets and the other 2? What is their relationship? Why would you have an Internet socket as well as a TCP socket?



      In short I am trying to understand all (have I missed any out?) the various different types of Unix sockets and under what circumstances I would use them?










      share|improve this question
















      I am reading The Linux Programming Interface and it describes several different types of socket used on Linux:



      • Unix domain

      • Berkeley

      • TCP

      • Internet

      One of the things the book said is that if you want to communicate between remote hosts, you couldn't use Unix domain sockets because they are for IPC on the same host. You have to use "Internet" sockets.



      However, I am still a little confused how this relates with "TCP" sockets, Berkeley sockets and the other 2? What is their relationship? Why would you have an Internet socket as well as a TCP socket?



      In short I am trying to understand all (have I missed any out?) the various different types of Unix sockets and under what circumstances I would use them?







      linux sockets unix tcp posix






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 2 '14 at 18:22









      ValenceElectron

      1,17651626




      1,17651626










      asked Apr 6 '14 at 18:16









      user997112user997112

      9,96827102219




      9,96827102219






















          1 Answer
          1






          active

          oldest

          votes


















          12














          A socket is an abstraction. The tag definition used on SO for a socket is as good as any:




          An endpoint of a bidirectional inter-process communication flow. This often refers to a process flow over a network connection, but by no means is limited to such.




          So from that a major distinction are sockets that (1) use a network and (2) sockets that do not.



          Unix domain sockets do not use the network. Their API makes it appear to be (mostly) the same to the developer as a network socket but all the communication is done through the kernel and the sockets are limited to talking to processes on the machine upon which they are running.



          Berkeley sockets are what we know as network sockets on POSIX platforms today. In the past there were different lines of Unix development (e.g. Berkeley or BSD, System V or sysV, etc.) Berkeley sockets essentially won in the marketplace and are effectively synonymous with Unix sockets today.



          Strictly speaking there isn't a TCP socket. There are network sockets that can communicate using the TCP protocol. It's just a linguist shorthand to refer to them as a TCP socket to distinguish them from a socket using another protocol e.g. UDP, a routing protocol or whatnot.



          An "Internet" socket is a mostly a meaningless distinction. It's a socket using a network protocol. That eliminates Unix domain sockets, but most network protocols can be used to communicate on a LAN or the Internet, which is just collection of networks. (Though do note there are protocols specific to local networks as well as those that manage collections of networks.)






          share|improve this answer




















          • 2





            Thanks for this. So am I right in thinking there are only really two raw sockets- POSIX/Berkeley and Unix domain. You can take the POSIX/Berkeley and "bolt-on" various settings which effectively turns it in to an "internet" socket, or a TCP socket- but you need a Berkeley/POSIX socket for the underlying?

            – user997112
            Apr 6 '14 at 19:32











          • That sounds about right. You might want to use the term "base" rather than "raw" since raw sockets imply IP layer datagrams without any transport level protocol formatting e..g tcp, udp, etc.

            – Duck
            Apr 6 '14 at 21:44










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22897972%2funix-vs-bsd-vs-tcp-vs-internet-sockets%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          12














          A socket is an abstraction. The tag definition used on SO for a socket is as good as any:




          An endpoint of a bidirectional inter-process communication flow. This often refers to a process flow over a network connection, but by no means is limited to such.




          So from that a major distinction are sockets that (1) use a network and (2) sockets that do not.



          Unix domain sockets do not use the network. Their API makes it appear to be (mostly) the same to the developer as a network socket but all the communication is done through the kernel and the sockets are limited to talking to processes on the machine upon which they are running.



          Berkeley sockets are what we know as network sockets on POSIX platforms today. In the past there were different lines of Unix development (e.g. Berkeley or BSD, System V or sysV, etc.) Berkeley sockets essentially won in the marketplace and are effectively synonymous with Unix sockets today.



          Strictly speaking there isn't a TCP socket. There are network sockets that can communicate using the TCP protocol. It's just a linguist shorthand to refer to them as a TCP socket to distinguish them from a socket using another protocol e.g. UDP, a routing protocol or whatnot.



          An "Internet" socket is a mostly a meaningless distinction. It's a socket using a network protocol. That eliminates Unix domain sockets, but most network protocols can be used to communicate on a LAN or the Internet, which is just collection of networks. (Though do note there are protocols specific to local networks as well as those that manage collections of networks.)






          share|improve this answer




















          • 2





            Thanks for this. So am I right in thinking there are only really two raw sockets- POSIX/Berkeley and Unix domain. You can take the POSIX/Berkeley and "bolt-on" various settings which effectively turns it in to an "internet" socket, or a TCP socket- but you need a Berkeley/POSIX socket for the underlying?

            – user997112
            Apr 6 '14 at 19:32











          • That sounds about right. You might want to use the term "base" rather than "raw" since raw sockets imply IP layer datagrams without any transport level protocol formatting e..g tcp, udp, etc.

            – Duck
            Apr 6 '14 at 21:44















          12














          A socket is an abstraction. The tag definition used on SO for a socket is as good as any:




          An endpoint of a bidirectional inter-process communication flow. This often refers to a process flow over a network connection, but by no means is limited to such.




          So from that a major distinction are sockets that (1) use a network and (2) sockets that do not.



          Unix domain sockets do not use the network. Their API makes it appear to be (mostly) the same to the developer as a network socket but all the communication is done through the kernel and the sockets are limited to talking to processes on the machine upon which they are running.



          Berkeley sockets are what we know as network sockets on POSIX platforms today. In the past there were different lines of Unix development (e.g. Berkeley or BSD, System V or sysV, etc.) Berkeley sockets essentially won in the marketplace and are effectively synonymous with Unix sockets today.



          Strictly speaking there isn't a TCP socket. There are network sockets that can communicate using the TCP protocol. It's just a linguist shorthand to refer to them as a TCP socket to distinguish them from a socket using another protocol e.g. UDP, a routing protocol or whatnot.



          An "Internet" socket is a mostly a meaningless distinction. It's a socket using a network protocol. That eliminates Unix domain sockets, but most network protocols can be used to communicate on a LAN or the Internet, which is just collection of networks. (Though do note there are protocols specific to local networks as well as those that manage collections of networks.)






          share|improve this answer




















          • 2





            Thanks for this. So am I right in thinking there are only really two raw sockets- POSIX/Berkeley and Unix domain. You can take the POSIX/Berkeley and "bolt-on" various settings which effectively turns it in to an "internet" socket, or a TCP socket- but you need a Berkeley/POSIX socket for the underlying?

            – user997112
            Apr 6 '14 at 19:32











          • That sounds about right. You might want to use the term "base" rather than "raw" since raw sockets imply IP layer datagrams without any transport level protocol formatting e..g tcp, udp, etc.

            – Duck
            Apr 6 '14 at 21:44













          12












          12








          12







          A socket is an abstraction. The tag definition used on SO for a socket is as good as any:




          An endpoint of a bidirectional inter-process communication flow. This often refers to a process flow over a network connection, but by no means is limited to such.




          So from that a major distinction are sockets that (1) use a network and (2) sockets that do not.



          Unix domain sockets do not use the network. Their API makes it appear to be (mostly) the same to the developer as a network socket but all the communication is done through the kernel and the sockets are limited to talking to processes on the machine upon which they are running.



          Berkeley sockets are what we know as network sockets on POSIX platforms today. In the past there were different lines of Unix development (e.g. Berkeley or BSD, System V or sysV, etc.) Berkeley sockets essentially won in the marketplace and are effectively synonymous with Unix sockets today.



          Strictly speaking there isn't a TCP socket. There are network sockets that can communicate using the TCP protocol. It's just a linguist shorthand to refer to them as a TCP socket to distinguish them from a socket using another protocol e.g. UDP, a routing protocol or whatnot.



          An "Internet" socket is a mostly a meaningless distinction. It's a socket using a network protocol. That eliminates Unix domain sockets, but most network protocols can be used to communicate on a LAN or the Internet, which is just collection of networks. (Though do note there are protocols specific to local networks as well as those that manage collections of networks.)






          share|improve this answer















          A socket is an abstraction. The tag definition used on SO for a socket is as good as any:




          An endpoint of a bidirectional inter-process communication flow. This often refers to a process flow over a network connection, but by no means is limited to such.




          So from that a major distinction are sockets that (1) use a network and (2) sockets that do not.



          Unix domain sockets do not use the network. Their API makes it appear to be (mostly) the same to the developer as a network socket but all the communication is done through the kernel and the sockets are limited to talking to processes on the machine upon which they are running.



          Berkeley sockets are what we know as network sockets on POSIX platforms today. In the past there were different lines of Unix development (e.g. Berkeley or BSD, System V or sysV, etc.) Berkeley sockets essentially won in the marketplace and are effectively synonymous with Unix sockets today.



          Strictly speaking there isn't a TCP socket. There are network sockets that can communicate using the TCP protocol. It's just a linguist shorthand to refer to them as a TCP socket to distinguish them from a socket using another protocol e.g. UDP, a routing protocol or whatnot.



          An "Internet" socket is a mostly a meaningless distinction. It's a socket using a network protocol. That eliminates Unix domain sockets, but most network protocols can be used to communicate on a LAN or the Internet, which is just collection of networks. (Though do note there are protocols specific to local networks as well as those that manage collections of networks.)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jul 23 '18 at 10:43









          François Beaune

          1,48942344




          1,48942344










          answered Apr 6 '14 at 18:48









          DuckDuck

          23k24977




          23k24977







          • 2





            Thanks for this. So am I right in thinking there are only really two raw sockets- POSIX/Berkeley and Unix domain. You can take the POSIX/Berkeley and "bolt-on" various settings which effectively turns it in to an "internet" socket, or a TCP socket- but you need a Berkeley/POSIX socket for the underlying?

            – user997112
            Apr 6 '14 at 19:32











          • That sounds about right. You might want to use the term "base" rather than "raw" since raw sockets imply IP layer datagrams without any transport level protocol formatting e..g tcp, udp, etc.

            – Duck
            Apr 6 '14 at 21:44












          • 2





            Thanks for this. So am I right in thinking there are only really two raw sockets- POSIX/Berkeley and Unix domain. You can take the POSIX/Berkeley and "bolt-on" various settings which effectively turns it in to an "internet" socket, or a TCP socket- but you need a Berkeley/POSIX socket for the underlying?

            – user997112
            Apr 6 '14 at 19:32











          • That sounds about right. You might want to use the term "base" rather than "raw" since raw sockets imply IP layer datagrams without any transport level protocol formatting e..g tcp, udp, etc.

            – Duck
            Apr 6 '14 at 21:44







          2




          2





          Thanks for this. So am I right in thinking there are only really two raw sockets- POSIX/Berkeley and Unix domain. You can take the POSIX/Berkeley and "bolt-on" various settings which effectively turns it in to an "internet" socket, or a TCP socket- but you need a Berkeley/POSIX socket for the underlying?

          – user997112
          Apr 6 '14 at 19:32





          Thanks for this. So am I right in thinking there are only really two raw sockets- POSIX/Berkeley and Unix domain. You can take the POSIX/Berkeley and "bolt-on" various settings which effectively turns it in to an "internet" socket, or a TCP socket- but you need a Berkeley/POSIX socket for the underlying?

          – user997112
          Apr 6 '14 at 19:32













          That sounds about right. You might want to use the term "base" rather than "raw" since raw sockets imply IP layer datagrams without any transport level protocol formatting e..g tcp, udp, etc.

          – Duck
          Apr 6 '14 at 21:44





          That sounds about right. You might want to use the term "base" rather than "raw" since raw sockets imply IP layer datagrams without any transport level protocol formatting e..g tcp, udp, etc.

          – Duck
          Apr 6 '14 at 21:44



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22897972%2funix-vs-bsd-vs-tcp-vs-internet-sockets%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          Evgeni Malkin