Writing binary data to a socket (or file) with Python - Stack Overflow
Writing binary data to a socket (or file) with Python