Welcome, guest | Sign In | My Account | Store | Cart

It's useful for transfering objects through socket, when doing communication between processes or networking.

Python, 10 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
def write(_socket, data):
    f = _socket.makefile('wb', buffer_size )
    pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)
    f.close()

def read(_socket):
    f = _socket.makefile('rb', buffer_size )
    data = pickle.load(f)
    f.close()
    return data
Created by pavel on Tue, 19 Apr 2011 (MIT)
Python recipes (4591)
pavel's recipes (5)

Required Modules

Other Information and Tasks