so far in this we've focused on the role of sockets in the classic client/server networking model that' one of their primary rolesbut they have other common use cases as well in for instancewe saw sockets as basic ipc device between processes and threads on single machine and in ' exploration of linking non-gui scripts to guiswe wrote utility module (example - which connected caller' standard output stream to socketon which gui could listen for output to be displayed therei promised that we' flesh out that module with additional transfer modes once we had chance to explore sockets in more depth now that we havethis section takes brief detour from the world of remote network servers to tell the rest of this story although some programs can be written or rewritten to converse over sockets explicitlythis isn' always an optionit may be too expensive an effort for existing scriptsand might preclude desirable nonsocket usage modes for others in some casesit' better to allow script to use standard stream tools such as the print and input built-in functions and sys module file calls ( sys stdout write)and connect them to sockets only when needed because such stream tools are designed to operate on text-mode filesthoughprobably the biggest trick here is fooling them into operating on the inherently binary mode and very different method interface of sockets luckilysockets come with method that achieves all the forgery we need the socket object makefile method comes in handy anytime you wish to process socket with normal file object methods or need to pass socket to an existing interface or program that expects file the socket wrapper object returned allows your scripts to transfer data over the underlying socket with read and write callsrather than recv and send since input and print built-in functions use the former methods setthey will happily interact with sockets wrapped by this calltoo the makefile method also allows us to treat normally binary socket data as text instead of byte stringsand has additional arguments such as encoding that let us specify nondefault unicode encodings for the transferred text--much like the built-in open and os fdopen calls we met in do for file descriptors although text can always be encoded and decoded with manual calls after binary mode socket transfersmake file shifts the burden of text encodings from your code to the file wrapper object this equivalence to files comes in handy any time we want to use software that supports file interfaces for examplethe python pickle module' load and dump methods expect an object with file-like interface ( read and write methods)but they don' require physical file passing tcp/ip socket wrapped with the makefile call to the pickler allows us to ship serialized python objects over the internetwithout having to pickle to byte strings ourselves and call raw socket methods manually this is an alternative to using the pickle module' string-based calls (dumpsloadswith socket send and making sockets look like files and streams