1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-22 03:30:22 +02:00

Have recv!', send', etc. accept a bytevector.

* libguile/socket.c (scm_recv, scm_send, scm_recvfrom, scm_sendto):
  Expect the buffer to be a bytevector.  Move the string-handling
  code under `#if SCM_ENABLE_DEPRECATED == 1' and issue a deprecation
  warning.

* test-suite/tests/socket.test ("AF_UNIX/SOCK_DGRAM")["sendto",
  "sendto/sockaddr"]: Adjust accordingly.

* doc/ref/posix.texi (Network Sockets and Communication): Update
  documentation of `recv!', `send', `recvfrom!', and `sendto'.
This commit is contained in:
Ludovic Courtès 2011-01-29 21:34:44 +01:00
parent 0bc2452b55
commit d21a1dc841
3 changed files with 184 additions and 89 deletions

View file

@ -1,22 +1,24 @@
;;;; socket.test --- test socket functions -*- scheme -*-
;;;;
;;;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;;;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010,
;;;; 2011 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
;;;; License as published by the Free Software Foundation; either
;;;; version 3 of the License, or (at your option) any later version.
;;;;
;;;;
;;;; This library is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;;;; Lesser General Public License for more details.
;;;;
;;;;
;;;; You should have received a copy of the GNU Lesser General Public
;;;; License along with this library; if not, write to the Free Software
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
(define-module (test-suite test-socket)
#:use-module (rnrs bytevectors)
#:use-module (test-suite lib))
@ -235,15 +237,17 @@
(pass-if "sendto"
(if (not server-bound?)
(throw 'unresolved)
(let ((client (socket AF_UNIX SOCK_DGRAM 0)))
(> (sendto client "hello" AF_UNIX path) 0))))
(let ((client (socket AF_UNIX SOCK_DGRAM 0))
(message (string->utf8 "hello")))
(> (sendto client message AF_UNIX path) 0))))
(pass-if "sendto/sockaddr"
(if (not server-bound?)
(throw 'unresolved)
(let ((client (socket AF_UNIX SOCK_DGRAM 0))
(let ((client (socket AF_UNIX SOCK_DGRAM 0))
(message (string->utf8 "hello"))
(sockaddr (make-socket-address AF_UNIX path)))
(> (sendto client "hello" sockaddr) 0))))
(> (sendto client message sockaddr) 0))))
(false-if-exception (delete-file path)))))