summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--socket.c2
-rw-r--r--txr.111
2 files changed, 11 insertions, 2 deletions
diff --git a/socket.c b/socket.c
index 2ea639fe..4e596a90 100644
--- a/socket.c
+++ b/socket.c
@@ -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) {
diff --git a/txr.1 b/txr.1
index 8dcc2c6b..8c3ea260 100644
--- a/txr.1
+++ b/txr.1
@@ -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