Skip to content

Instantly share code, notes, and snippets.

@agronholm
Last active December 23, 2019 12:10
Show Gist options
  • Save agronholm/e2cfa9c668838fdec4fc08f17040328e to your computer and use it in GitHub Desktop.
Save agronholm/e2cfa9c668838fdec4fc08f17040328e to your computer and use it in GitHub Desktop.
import os
import socket
from threading import Thread
def serve():
global accepted_client
accepted_client = server.accept()
accepted_client = None
server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
server.bind('/tmp/blah.sock')
try:
server.listen()
t = Thread(target=serve)
t.start()
client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
client.connect('/tmp/blah.sock')
client.settimeout(None)
n = client.send(b'\x00' * 1024_000)
print('sent: %d' % n)
t.join()
finally:
server.close()
os.unlink('/tmp/blah.sock')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment