From: Chris Hanson Date: Wed, 9 Jul 2003 04:27:03 +0000 (+0000) Subject: Split OPEN-TCP-SERVER-SOCKET into its component parts. X-Git-Tag: 20090517-FFI~1882 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=9bec87a6071c4bca1513ff23f4503a66a0bd6646;p=mit-scheme.git Split OPEN-TCP-SERVER-SOCKET into its component parts. --- diff --git a/v7/src/runtime/runtime.pkg b/v7/src/runtime/runtime.pkg index 41110766d..1bf236c43 100644 --- a/v7/src/runtime/runtime.pkg +++ b/v7/src/runtime/runtime.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: runtime.pkg,v 14.447 2003/06/08 05:07:12 cph Exp $ +$Id: runtime.pkg,v 14.448 2003/07/09 04:27:03 cph Exp $ Copyright 1988,1989,1990,1991,1992,1993 Massachusetts Institute of Technology Copyright 1994,1995,1996,1997,1998,1999 Massachusetts Institute of Technology @@ -3029,13 +3029,16 @@ USA. (parent (runtime)) (export () allocate-host-address + bind-tcp-server-socket canonical-host-name close-tcp-server-socket + create-tcp-server-socket get-host-by-address get-host-by-name get-host-name host-address-any host-address-loopback + listen-tcp-server-socket open-tcp-server-socket open-tcp-stream-socket open-tcp-stream-socket-channel diff --git a/v7/src/runtime/socket.scm b/v7/src/runtime/socket.scm index f998ba27e..9db1ac97f 100644 --- a/v7/src/runtime/socket.scm +++ b/v7/src/runtime/socket.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: socket.scm,v 1.22 2003/06/08 03:36:11 cph Exp $ +$Id: socket.scm,v 1.23 2003/07/09 04:26:50 cph Exp $ Copyright 1996,1997,1998,1999,2001,2002 Massachusetts Institute of Technology Copyright 2003 Massachusetts Institute of Technology @@ -65,20 +65,29 @@ USA. ((ucode-primitive new-open-unix-stream-socket 2) filename p)))))) (define (open-tcp-server-socket service #!optional host) + (let ((server-socket (create-tcp-server-socket))) + (bind-tcp-server-socket server-socket + service + (if (or (default-object? host) (not host)) + ((ucode-primitive host-address-any 0)) + host)) + (listen-tcp-server-socket server-socket))) + +(define (create-tcp-server-socket) (open-channel (lambda (p) - (with-thread-timer-stopped - (lambda () - (let ((channel ((ucode-primitive create-tcp-server-socket 0)))) - (system-pair-set-cdr! p channel) - ((ucode-primitive bind-tcp-server-socket 3) - channel - (if (or (default-object? host) (not host)) - ((ucode-primitive host-address-any 0)) - host) - (tcp-service->port service)) - ((ucode-primitive listen-tcp-server-socket 1) channel)) - #t))))) + (system-pair-set-cdr! p ((ucode-primitive create-tcp-server-socket 0))) + #t))) + +(define (bind-tcp-server-socket server-socket service host) + ((ucode-primitive bind-tcp-server-socket 3) + (channel-descriptor server-socket) + host + (tcp-service->port service))) + +(define (listen-tcp-server-socket server-socket) + ((ucode-primitive listen-tcp-server-socket 1) + (channel-descriptor server-socket))) (define (tcp-service->port service) (if (exact-nonnegative-integer? service)