Skip to content

Instantly share code, notes, and snippets.

@xtrinch
Last active November 25, 2017 01:16
Show Gist options
  • Save xtrinch/09d8fa95c2001c53ccc10a02bf1b6a93 to your computer and use it in GitHub Desktop.
Save xtrinch/09d8fa95c2001c53ccc10a02bf1b6a93 to your computer and use it in GitHub Desktop.
Simple websocket binary data send simulation
#!/usr/bin/env python
import time
import socket
HOST = 'localhost'
PORT = 9876
ADDR = (HOST, PORT)
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket.bind(ADDR)
serversocket.listen(1)
print("Will start waiting for clients.")
while 1:
# wait for the client to connect
connnection, address = serversocket.accept()
while 1:
# continuously send binary packet every 500ms
connnection.send('10000000000000000000000000000000000000000000'.decode('hex'))
time.sleep(0.5)
time.sleep(1)
print("Sleeping.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment