Skip to content

Debugging with echo over socket #31

Description

@abitrolly
  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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions