Advertisement
Azelphur

Untitled

Jun 1st, 2011
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import socket, time
  4.  
  5. def handle(s):
  6.     print repr(s.recv(4096))
  7.     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''')
  8.     s.send("\x00hi\xff")
  9.     #s.close()
  10.  
  11. s = socket.socket()
  12. s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
  13. s.bind(('', 9998));
  14. s.listen(1);
  15. while 1:
  16.     t,_ = s.accept();
  17.     handle(t)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement