Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import socket, time
- def handle(s):
- print repr(s.recv(4096))
- s.send('''HTTP/1.1 101 Web Socket Protocol Handshake\rUpgrade: WebSocket\rConnection: Upgrade\rWebSocket-Origin: http://azelphur.com/test.html\rWebSocket-Location: ws://azelphur.com:9998/\rWebSocket-Protocol: sample\r\n\r\n''')
- s.send("\x00hi\xff")
- #s.close()
- s = socket.socket()
- s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- s.bind(('', 9998));
- s.listen(1);
- while 1:
- t,_ = s.accept();
- handle(t)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement