Skip to content

Instantly share code, notes, and snippets.

View patrickhulce's full-sized avatar
😎
Live, eat, breathe JS

Patrick Hulce patrickhulce

😎
Live, eat, breathe JS
View GitHub Profile
@patrickhulce
patrickhulce / sockets.py
Created April 7, 2013 05:23
Working with web sockets.
#!/usr/bin/env python
import socket, threading, time, re
from base64 import b64encode
from hashlib import sha1
def handle(s,a):
print a
handshake_data = s.recv(4096)
print handshake_data
client_key = re.search("Sec-WebSocket-Key:\s+(.*?)[\n\r]+", handshake_data).groups()[0].strip()