Find out details of a socket by the socket's path name?












0















I ran an strace on a client application failure and got something like this:



socket(PF_LOCAL, SOCK_SEQPACKET|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
setsockopt(3, SOL_SOCKET, SO_PASSCRED, [1], 4) = 0
connect(3, {sa_family=AF_LOCAL, sun_path="/path/to/socket"}, 19) = -1 EPROTOTYPE (Protocol wrong type for socket)
close(3) = 0
exit_group(2) = ?
+++ exited with 2 +++


I then tried to guess the socket type by emulating the socket in place with various parameters to socat, but to no avail.



I also looked at the code from this answer here, but it appears to be making a socket, not using an existing one, and I can't seem to find how to get a socket from a path.



Without digging through the source code, is there an easy way to determine the details (such as the protocol type) of an existing socket from the socket's path (if it exists)?










share|improve this question
















bumped to the homepage by Community 4 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    0















    I ran an strace on a client application failure and got something like this:



    socket(PF_LOCAL, SOCK_SEQPACKET|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
    setsockopt(3, SOL_SOCKET, SO_PASSCRED, [1], 4) = 0
    connect(3, {sa_family=AF_LOCAL, sun_path="/path/to/socket"}, 19) = -1 EPROTOTYPE (Protocol wrong type for socket)
    close(3) = 0
    exit_group(2) = ?
    +++ exited with 2 +++


    I then tried to guess the socket type by emulating the socket in place with various parameters to socat, but to no avail.



    I also looked at the code from this answer here, but it appears to be making a socket, not using an existing one, and I can't seem to find how to get a socket from a path.



    Without digging through the source code, is there an easy way to determine the details (such as the protocol type) of an existing socket from the socket's path (if it exists)?










    share|improve this question
















    bumped to the homepage by Community 4 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      I ran an strace on a client application failure and got something like this:



      socket(PF_LOCAL, SOCK_SEQPACKET|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
      setsockopt(3, SOL_SOCKET, SO_PASSCRED, [1], 4) = 0
      connect(3, {sa_family=AF_LOCAL, sun_path="/path/to/socket"}, 19) = -1 EPROTOTYPE (Protocol wrong type for socket)
      close(3) = 0
      exit_group(2) = ?
      +++ exited with 2 +++


      I then tried to guess the socket type by emulating the socket in place with various parameters to socat, but to no avail.



      I also looked at the code from this answer here, but it appears to be making a socket, not using an existing one, and I can't seem to find how to get a socket from a path.



      Without digging through the source code, is there an easy way to determine the details (such as the protocol type) of an existing socket from the socket's path (if it exists)?










      share|improve this question
















      I ran an strace on a client application failure and got something like this:



      socket(PF_LOCAL, SOCK_SEQPACKET|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
      setsockopt(3, SOL_SOCKET, SO_PASSCRED, [1], 4) = 0
      connect(3, {sa_family=AF_LOCAL, sun_path="/path/to/socket"}, 19) = -1 EPROTOTYPE (Protocol wrong type for socket)
      close(3) = 0
      exit_group(2) = ?
      +++ exited with 2 +++


      I then tried to guess the socket type by emulating the socket in place with various parameters to socat, but to no avail.



      I also looked at the code from this answer here, but it appears to be making a socket, not using an existing one, and I can't seem to find how to get a socket from a path.



      Without digging through the source code, is there an easy way to determine the details (such as the protocol type) of an existing socket from the socket's path (if it exists)?







      unix-sockets






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 23 '17 at 12:40









      Community

      1




      1










      asked Apr 11 '17 at 6:39









      tudortudor

      215213




      215213





      bumped to the homepage by Community 4 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 4 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You can use lsof /path/to/socket:



          COMMAND     PID USER   FD   TYPE             DEVICE SIZE/OFF      NODE NAME
          hindsight 19619 root 6u unix 0xffff88038612b480 0t0 257123917 /path/to/socket


          Knowing the PID you can find out more about the process itself:



          cat /proc/19619/io 
          rchar: 11635200437
          wchar: 2722080850
          syscr: 16905056
          syscw: 920240
          read_bytes: 36397568
          write_bytes: 3515994112
          cancelled_write_bytes: 760422400


          Or you could use ss for displaying all Unix sockets.



          ss -x




          • -x Display Unix domain sockets


          • -e Show detailed socket information


          • -m Show socket memory usage


          and you can filter for some type:



          ss -x -A unix_stream





          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            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: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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%2funix.stackexchange.com%2fquestions%2f358237%2ffind-out-details-of-a-socket-by-the-sockets-path-name%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









            0














            You can use lsof /path/to/socket:



            COMMAND     PID USER   FD   TYPE             DEVICE SIZE/OFF      NODE NAME
            hindsight 19619 root 6u unix 0xffff88038612b480 0t0 257123917 /path/to/socket


            Knowing the PID you can find out more about the process itself:



            cat /proc/19619/io 
            rchar: 11635200437
            wchar: 2722080850
            syscr: 16905056
            syscw: 920240
            read_bytes: 36397568
            write_bytes: 3515994112
            cancelled_write_bytes: 760422400


            Or you could use ss for displaying all Unix sockets.



            ss -x




            • -x Display Unix domain sockets


            • -e Show detailed socket information


            • -m Show socket memory usage


            and you can filter for some type:



            ss -x -A unix_stream





            share|improve this answer




























              0














              You can use lsof /path/to/socket:



              COMMAND     PID USER   FD   TYPE             DEVICE SIZE/OFF      NODE NAME
              hindsight 19619 root 6u unix 0xffff88038612b480 0t0 257123917 /path/to/socket


              Knowing the PID you can find out more about the process itself:



              cat /proc/19619/io 
              rchar: 11635200437
              wchar: 2722080850
              syscr: 16905056
              syscw: 920240
              read_bytes: 36397568
              write_bytes: 3515994112
              cancelled_write_bytes: 760422400


              Or you could use ss for displaying all Unix sockets.



              ss -x




              • -x Display Unix domain sockets


              • -e Show detailed socket information


              • -m Show socket memory usage


              and you can filter for some type:



              ss -x -A unix_stream





              share|improve this answer


























                0












                0








                0







                You can use lsof /path/to/socket:



                COMMAND     PID USER   FD   TYPE             DEVICE SIZE/OFF      NODE NAME
                hindsight 19619 root 6u unix 0xffff88038612b480 0t0 257123917 /path/to/socket


                Knowing the PID you can find out more about the process itself:



                cat /proc/19619/io 
                rchar: 11635200437
                wchar: 2722080850
                syscr: 16905056
                syscw: 920240
                read_bytes: 36397568
                write_bytes: 3515994112
                cancelled_write_bytes: 760422400


                Or you could use ss for displaying all Unix sockets.



                ss -x




                • -x Display Unix domain sockets


                • -e Show detailed socket information


                • -m Show socket memory usage


                and you can filter for some type:



                ss -x -A unix_stream





                share|improve this answer













                You can use lsof /path/to/socket:



                COMMAND     PID USER   FD   TYPE             DEVICE SIZE/OFF      NODE NAME
                hindsight 19619 root 6u unix 0xffff88038612b480 0t0 257123917 /path/to/socket


                Knowing the PID you can find out more about the process itself:



                cat /proc/19619/io 
                rchar: 11635200437
                wchar: 2722080850
                syscr: 16905056
                syscw: 920240
                read_bytes: 36397568
                write_bytes: 3515994112
                cancelled_write_bytes: 760422400


                Or you could use ss for displaying all Unix sockets.



                ss -x




                • -x Display Unix domain sockets


                • -e Show detailed socket information


                • -m Show socket memory usage


                and you can filter for some type:



                ss -x -A unix_stream






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 11 '17 at 8:30









                TombartTombart

                91521626




                91521626






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • 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%2funix.stackexchange.com%2fquestions%2f358237%2ffind-out-details-of-a-socket-by-the-sockets-path-name%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

                    サソリ

                    広島県道265号伴広島線

                    Setup Asymptote in Texstudio