tcp_output_stream(?Socket, -Stream)

Returns the output stream Stream from the socket file descriptor term Socket. You can write to the stream using the regular stream output predicates.

Output on socket streams are buffered. If you want to send characters one at a time, you must follow each write with a flush, as in

     tcp_output_stream(Socket, Stream),
     put(Stream, Character),
     flush_output(Stream)
     

If you try to write to a broken socket, the "Broken pipe" exception is raised:

     existence_error(_,_,_,_,errno(32))