Package: cmucl Version: 19a-release-20040728-9 Severity: wishlist Tags: patch
This is a simple request to add packaging of certain POSIX socket operations to CMUCL. The packaging is perfectly straightforward, and has been tested extensively in the application for which I developed them. I post them to the Debian BTS because 1) I thought other people might profit from using these extensions 2) CMUCL itself does not seem to have a good place for posting such requests I have tried to match the style of the existing implementation for stream-based networking as far as possible. This code must be added to a suitable place in cmucl/code/unix-glibc2.lisp: ====================================================================== (export '(unix-recv-from unix-send-to unix-shutdown)) (def-alien-routine ("recvfrom" unix-recv-from) int (fd int) (buffer c-string) (length int) (flags int) (sockaddr (* t)) (len int :in-out)) (def-alien-routine ("sendto" unix-send-to) int (fd int) (buffer c-string) (length int) (flags int) (sockaddr (* t)) (len int)) (def-alien-routine ("shutdown" unix-shutdown) int (socket int) (level int)) ====================================================================== This code must be added to a suitable place in cmucl/code/internet.lisp: ====================================================================== (export '(recvfrom sendto shutdown shut-rd shut-wr shut-rdwr)) (defun recvfrom (fd buffer size &key (flags 0)) "A packaging of the unix recvfrom call. Returns three values: bytecount, source address as integer, and source port. bytecount can of course be negative, to indicate faults." (mp:process-wait-until-fd-usable fd :input) (with-alien ((sockaddr inet-sockaddr)) (let* ((bytecount (unix:unix-recv-from fd buffer size flags (alien-sap sockaddr) (alien-size inet-sockaddr :bytes)))) (values bytecount (ntohl (slot sockaddr 'addr)) (ntohs (slot sockaddr 'port)))))) (defun sendto (fd buffer size addr port &key (flags 0)) "A packaging of the unix sendto call. Return value like sendto" (with-alien ((sockaddr inet-sockaddr)) (setf (slot sockaddr 'family) af-inet) (setf (slot sockaddr 'port) (htons port)) (setf (slot sockaddr 'addr) (htonl addr)) (unix:unix-send-to fd buffer size flags (alien-sap sockaddr) (alien-size inet-sockaddr :bytes)))) (defconstant shut-rd 0) (defconstant shut-wr 1) (defconstant shut-rdwr 2) (defun shutdown (fd level) (when (minusp (unix:unix-shutdown fd level)) (error "Error on shutdown of socket: ~A" (unix:get-unix-error-msg)))) ====================================================================== A natural question is: is it not necessary to modify ext:create-inet-listener and ext:create-inet-socket to use these extensions? The answer is, that they work already; current version of "internet.lisp" has support to open a datagram socket, but not to use it! -- System Information: Debian Release: 3.1 APT prefers unstable APT policy: (500, 'unstable') Architecture: i386 (i686) Kernel: Linux 2.6.5-7.97-smp Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) Versions of packages cmucl depends on: ii common-lisp-controller 4.12 This is a Common Lisp source and c ii debconf 1.4.41 Debian configuration management sy -- debconf information: cmucl/upgradeproblems: -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]