Change OPEN-TCP-STREAM-SOCKET and OPEN-UNIX-STREAM-SOCKET to return
authorChris Hanson <org/chris-hanson/cph>
Sat, 1 Nov 1997 19:19:39 +0000 (19:19 +0000)
committerChris Hanson <org/chris-hanson/cph>
Sat, 1 Nov 1997 19:19:39 +0000 (19:19 +0000)
one port instead of two, and to allow optional arguments to specify
the buffer size and line translation.  Increase the default buffer
size to 4096 bytes.

v7/src/runtime/socket.scm

index 9719293413d44c82099f61f64a23c616b7f89277..5c8736bc1f0c17bd319dc4310c17c71db5c69a83 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: socket.scm,v 1.9 1997/11/01 07:31:40 cph Exp $
+$Id: socket.scm,v 1.10 1997/11/01 19:19:39 cph Exp $
 
 Copyright (c) 1990-97 Massachusetts Institute of Technology
 
@@ -37,15 +37,24 @@ MIT in each case. |#
 
 (declare (usual-integrations))
 \f
-(define (open-tcp-stream-socket host-name service)
-  (socket-ports (open-tcp-stream-socket-channel host-name service)))
-
-(define (open-unix-stream-socket filename)
-  (socket-ports (open-unix-stream-socket-channel filename)))
-
-(define (socket-ports channel)
-  (let ((port (make-generic-i/o-port channel channel 64 64)))
-    (values port port)))
+(define (open-tcp-stream-socket host-name service
+                               #!optional buffer-size line-translation)
+  (socket-port (open-tcp-stream-socket-channel host-name service)
+              (if (default-object? buffer-size) #f buffer-size)
+              (if (default-object? line-translation) #f line-translation)))
+
+(define (open-unix-stream-socket filename
+                               #!optional buffer-size line-translation)
+  (socket-port (open-unix-stream-socket-channel filename)
+              (if (default-object? buffer-size) #f buffer-size)
+              (if (default-object? line-translation) #f line-translation)))
+
+(define (socket-ports channel buffer-size line-translation)
+  (let ((buffer-size (or buffer-size 4096))
+       (line-translation (or line-translation 'DEFAULT)))
+    (make-generic-i/o-port channel channel
+                          buffer-size buffer-size
+                          line-translation line-translation)))
 
 (define (open-tcp-stream-socket-channel host-name service)
   (let ((host (vector-ref (get-host-by-name host-name) 0))