Last active
December 23, 2019 12:10
-
-
Save agronholm/e2cfa9c668838fdec4fc08f17040328e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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