Rewrite get_socket() function for use with Python older than 2.6
Merge branch 'kk'