net.lisp Basic sbcl sb-bsd-sockets support

Philippe Brochard <[email protected]> Tue, 20 Jun 2006 22:10:36 +0200
Newsgroups gmane.lisp.clocc.general
Organization GNU/Linux Home
Message-ID <[email protected]>
--=-=-=

Hi all,

here is a patch to clocc/net.lisp to support sbcl/sb-bsd-sockets.

open-socket-server, socket-accept, open-socket,
socket-server-close and socket-server-host/port seems to work for
me. But I don't know how to write socket-host/port.


Regards,

Philippe



-- 
Philippe Brochard    <[email protected]>
                      http://hocwp.free.fr

-=-= http://www.gnu.org/home.fr.html =-=-

--=-=-=
Content-Disposition: inline; filename=net.lisp.diff

Index: net.lisp
===================================================================
RCS file: /cvsroot/clocc/clocc/src/port/net.lisp,v
retrieving revision 1.59
diff -r1.59 net.lisp
20c20,24
<   #+lispworks (require "comm"))
---
>   #+lispworks (require "comm")
>   #+(and sbcl (not (or db-sockets net.sbcl.sockets)))
>   (progn
>     (require :sb-bsd-sockets)
>     (pushnew :sb-bsd-sockets *features*)))
63c67
< ;#+(and sbcl db-sockets)
---
> ;#+(and sbcl (or db-sockets sb-bsd-sockets))
66c70
< #+(and sbcl db-sockets)
---
> #+(and sbcl (or db-sockets sb-bsd-sockets))
73c77
< ;#+(and sbcl db-sockets)
---
> ;#+(and sbcl (or db-sockets sb-bsd-sockets))
76c80
< #+(and sbcl db-sockets)
---
> #+(and sbcl (or db-sockets sb-bsd-sockets))
82a87,90
> 
> 
> 
> 
181a190
>   #+(and sbcl sb-bsd-sockets) 'sb-sys:fd-stream
183c192
< 	(and sbcl (or db-sockets net.sbcl.sockets)) scl) 'stream)
---
> 	(and sbcl (or db-sockets net.sbcl.sockets sb-bsd-sockets)) scl) 'stream)
223a233,242
>     #+(and sbcl sb-bsd-sockets)
>     (let ((socket (make-instance 'sb-bsd-sockets:inet-socket
>                                  :type :stream :protocol :tcp)))
>       (sb-bsd-sockets:socket-connect socket
> 				     (sb-bsd-sockets::host-ent-address
> 				      (sb-bsd-sockets:get-host-by-name host))
> 				     port)
>       (sb-bsd-sockets:socket-make-stream
>        socket :input t :output t :buffering (if bin :none :line)
>        :element-type (if bin '(unsigned-byte 8) 'character)))
225c244
<           (and sbcl (or net.sbcl.sockets db-sockets)) scl)
---
>           (and sbcl (or net.sbcl.sockets db-sockets sb-bsd-sockets)) scl)
281a301,303
>   (dbg sock)
>   #+(and sbcl sb-bsd-sockets)
>   (values "?" 0 "?" 0) ; Don't know how to do this :(
283c305
<         (and sbcl (or net.sbcl.sockets db-sockets)) scl)
---
>         (and sbcl (or net.sbcl.sockets db-sockets sb-bsd-sockets)) scl)
309a332
>   #+(and sbcl sb-bsd-sockets) 'sb-bsd-sockets:inet-socket
338a362,369
>   #+(and sbcl sb-bsd-sockets)
>   (let ((sock (make-instance 'sb-bsd-sockets:inet-socket
>                              :type :stream
>                              :protocol :tcp)))
>     (setf (sb-bsd-sockets:sockopt-reuse-address sock) t)
>     (sb-bsd-sockets:socket-bind  sock (vector 0 0 0 0) (or port 0))
>     (sb-bsd-sockets:socket-listen sock 1)
>     sock)
340c371
<         (and sbcl (or net.sbcl.sockets db-sockets)) scl)
---
>         (and sbcl (or net.sbcl.sockets db-sockets sb-bsd-sockets)) scl)
406a438,443
>   #+(and sbcl sb-bsd-sockets)
>   (let ((s (sb-bsd-sockets:socket-accept serv)))
>     (sb-bsd-sockets:socket-make-stream s
>                                        :input t :output t
>                                        :element-type (if bin '(unsigned-byte 8) 'character)
>                                        :buffering :full))
408c445
<         (and sbcl (or net.sbcl.sockets db-sockets)) scl)
---
>         (and sbcl (or net.sbcl.sockets db-sockets sb-bsd-sockets)) scl)
423a461
>   #+(and sbcl sb-bsd-sockets) (sb-bsd-sockets:socket-close server)
425c463
<         (and sbcl (or net.sbcl.sockets db-sockets)) scl)
---
>         (and sbcl (or net.sbcl.sockets db-sockets sb-bsd-sockets)) scl)
453a492,494
>   #+(and sbcl sb-bsd-sockets)
>   (multiple-value-bind (addr port) (sb-bsd-sockets:socket-name server)
>     (values (ipaddr-to-dotted (vector-to-ipaddr addr)) port))
455c496
<         (and sbcl (or net.sbcl.sockets db-sockets)) scl)
---
>         (and sbcl (or net.sbcl.sockets db-sockets sb-bsd-sockets)) scl)

--=-=-=
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--=-=-=
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
clocc-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clocc-list

--=-=-=--