files require byte strings insteadwhen dealing with the raw socket directlythoughtext must still be manually encoded to byte stringsas shown in most of example - ' tests buffered streamsprogram outputand deadlock as we learned in and standard streams are normally bufferedand printed text may need to be flushed so that it appears on socket connected to process' output stream indeedsome of this example' tests require explicit or implicit flush calls to work properly at allotherwise their output is either incomplete or absent altogether until program exit in pathological casesthis can lead to deadlockwith process waiting for output from another that never appears in other configurationswe may also get socket errors in reader if writer exits too soonespecially in two-way dialogs for exampleif client and client did not flush periodically as they dothe only reason that they would work is because output streams are automatically flushed when their process exits without manual flushesclient transfers no data until process exit (at which point all its output is sent at once in single message)and client ' data is incomplete till exit (its last printed message is delayedeven more subtlyboth client and client rely on the fact that the input builtin first automatically flushes sys stdout internally for its prompt optionthereby sending data from preceding print calls without this implicit flush (or the addition of manual flushes)client would experience deadlock immediatelyas would client if its manual flush call was removed (even with input' flushremoving client ' manual flush causes its final print message to not be transferred until process exitclient has this same behavior as client because it simply swaps which process binds and accepts and which connects in the general caseif we wish to read program' output as it is producedinstead of all at once when it exits or as its buffers fillthe program must either call sys stdout flush periodicallyor be run with unbuffered streams by using python' - command-line argument of if applicable although we can open socket wrapper files in unbuffered mode with second makefile argument of zero (like normal open)this does not allow the wrapper to run in the text mode required for print and desired for input in factattempting to make socket wrapper file both text mode and unbuffered this way fails with an exceptionbecause python no longer supports unbuffered mode for text files (it is allowed for binary mode only todayin other wordsbecause print requires text modebuffered mode is also implied for output stream files moreoverattempting to open socket file wrapper in line-buffered mode appears to not be supported in python (more on this aheadwhile some buffering behavior may be library and platform dependentmanual flush calls or direct socket access might sometimes still be required note that sockets can also be made nonblocking with the setblocking( methodbut this making sockets look like files and streams