Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging with echo over socket #31

Open
abitrolly opened this issue Oct 10, 2019 · 1 comment
Open

Debugging with echo over socket #31

abitrolly opened this issue Oct 10, 2019 · 1 comment

Comments

@abitrolly
Copy link
Member

  1. Open local socket to listen to incoming echoes.
$ nc -Ulk /tmp/socket
# -U  - open unix socket
# -l  - open for listening
# -k  - keep open for multiple connections
  1. Add echo function to Python code
import socket
conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
conn.connect('/tmp/socket')
# ^ this will fail if nobody is listening on Unix socket

def echo(msg):
    conn.sendall(msg + '\n')
echo('--- start ---')
echo(sys.executable)
@abitrolly
Copy link
Member Author

Error for conn.connect on Unix socket.

  • socket.error: [Errno 111] Connection refused - socket file exists, but nobody listening
  • socket.error: [Errno 2] No such file or directory - socket file doesn't exist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant