Skip to content

Instantly share code, notes, and snippets.

@brain-zhang
Forked from nuxlli/unix_socket_request.sh
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save brain-zhang/a0818763c7e09b00034e to your computer and use it in GitHub Desktop.

Select an option

Save brain-zhang/a0818763c7e09b00034e to your computer and use it in GitHub Desktop.

Revisions

  1. @nuxlli nuxlli revised this gist Nov 20, 2013. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion request.sh
    Original file line number Diff line number Diff line change
    @@ -14,4 +14,7 @@
    echo -e "GET /images/json HTTP/1.1\r\n" | socat unix-connect:/var/run/docker.sock STDIO

    # nc version (netcat-freebsd)
    echo -e "GET /images/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock
    echo -e "GET /images/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock

    # bonus round: relay socket
    socat -d -d TCP-L:8080,fork UNIX:/var/run/docker.sock
  2. @nuxlli nuxlli revised this gist Nov 19, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions request.sh
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@
    # http://ubuntuforums.org/showthread.php?t=828870

    # Socat version
    echo -e "GET /images/json HTTP/1.1\r\n" | ./private/socat unix-connect:/var/run/docker.sock STDIO
    echo -e "GET /images/json HTTP/1.1\r\n" | socat unix-connect:/var/run/docker.sock STDIO

    # nc version (netcat-freebsd)
    echo -e "GET /images/json HTTP/1.0\r\n" | ./private/nc -U /var/run/docker.sock
    echo -e "GET /images/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock
  3. @nuxlli nuxlli created this gist Nov 19, 2013.
    17 changes: 17 additions & 0 deletions request.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/bin/bash

    # References
    # http://www.computerhope.com/unix/nc.htm#03
    # https://github.com/daniloegea/netcat
    # http://unix.stackexchange.com/questions/26715/how-can-i-communicate-with-a-unix-domain-socket-via-the-shell-on-debian-squeeze
    # http://unix.stackexchange.com/questions/33924/write-inside-a-socket-open-by-another-process-in-linux/33982#33982
    # http://www.linuxjournal.com/content/more-using-bashs-built-devtcp-file-tcpip
    # http://www.dest-unreach.org/socat/
    # http://stuff.mit.edu/afs/sipb/machine/penguin-lust/src/socat-1.7.1.2/EXAMPLES
    # http://ubuntuforums.org/showthread.php?t=828870

    # Socat version
    echo -e "GET /images/json HTTP/1.1\r\n" | ./private/socat unix-connect:/var/run/docker.sock STDIO

    # nc version (netcat-freebsd)
    echo -e "GET /images/json HTTP/1.0\r\n" | ./private/nc -U /var/run/docker.sock