import socket, os, sys sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # host running "nc -l -p 9330 < /dev/zero" or something similar sock.connect(("a.b.c.d", 9330)) # may need a larger size to replicate size = 6464478 file = sock.makefile('rb') data = file.read(size) sock.close