Last active
November 25, 2017 01:16
-
-
Save xtrinch/09d8fa95c2001c53ccc10a02bf1b6a93 to your computer and use it in GitHub Desktop.
Simple websocket binary data send simulation
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
#!/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