diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-03-18 06:45:20 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-03-18 06:45:20 -0700 |
commit | 54ab368d20df1796106e2dae222a3b926c331dd9 (patch) | |
tree | 38a7759fb750a78183e4389ae8ac786afd5c753c | |
parent | 1ef8071c738db67214e7d20502496146d2a40821 (diff) | |
download | txr-54ab368d20df1796106e2dae222a3b926c331dd9.tar.gz txr-54ab368d20df1796106e2dae222a3b926c331dd9.tar.bz2 txr-54ab368d20df1796106e2dae222a3b926c331dd9.zip |
Sockets are r+b by default, not r+.
* socket.c (open_sockfd): Default mode string is "r+b".
* txr.1: Documented.
-rw-r--r-- | socket.c | 2 | ||||
-rw-r--r-- | txr.1 | 11 |
2 files changed, 11 insertions, 2 deletions
@@ -943,7 +943,7 @@ val open_sockfd(val fd, val family, val type, val mode_str_in) return make_dgram_sock_stream(c_num(fd), family, nil, 0, 0, 0, 0); } else { struct stdio_mode m; - val mode_str = default_arg(mode_str_in, lit("r+")); + val mode_str = default_arg(mode_str_in, lit("r+b")); FILE *f = (errno = 0, w_fdopen(c_num(fd), c_str(normalize_mode(&m, mode_str)))); if (!f) { @@ -37845,10 +37845,19 @@ argument is different under .code open-socket from other functions. Because sockets are almost always used for bidirectional data flow, the default mode string is -.str r+ +.str r+b rather than the usual .strn r . +Rationale for including the +.str b +flag in the default mode string is that network protocols are usually defined +in a way that is independent of machine and operating system, down to the byte +level, even when they are textual. It doesn't make sense for the same \*(TX +program to see a network stream differently based on what platform it is +running on. Line ending conversion has to do with how a platform locally stores +text files, whereas network streams are almost always external formats. + Like other stream times, stream sockets are buffered and marked as no non-real-time streams. Specifying the .str i |