diff options
Diffstat (limited to 'libguile/socket.c')
-rw-r--r-- | libguile/socket.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/libguile/socket.c b/libguile/socket.c index 18750a35f..e9523743c 100644 --- a/libguile/socket.c +++ b/libguile/socket.c @@ -34,6 +34,7 @@ #include "libguile/vectors.h" #include "libguile/dynwind.h" #include "libguile/srfi-13.h" +#include "libguile/strings.h" #include "libguile/validate.h" #include "libguile/socket.h" @@ -1450,7 +1451,7 @@ SCM_DEFINE (scm_recv, "recv!", 2, 1, 0, if (rv == -1) SCM_SYSERROR; - scm_remember_upto_here_1 (buf); + scm_remember_upto_here_2 (buf, msg); return scm_from_int (rv); } #undef FUNC_NAME @@ -1482,9 +1483,13 @@ SCM_DEFINE (scm_send, "send", 2, 1, 0, sock = SCM_COERCE_OUTPORT (sock); SCM_VALIDATE_OPFPORT (1, sock); SCM_VALIDATE_STRING (2, message); - if (!scm_i_is_narrow_string (message)) + + /* If the string is wide, see if it can be coerced into + a narrow string. */ + if (!scm_i_is_narrow_string (message) + || scm_i_try_narrow_string (message)) SCM_MISC_ERROR ("the message string is not 8-bit: ~s", - scm_list_1 (message)); + scm_list_1 (message)); if (SCM_UNBNDP (flags)) flg = 0; @@ -1492,9 +1497,11 @@ SCM_DEFINE (scm_send, "send", 2, 1, 0, flg = scm_to_int (flags); fd = SCM_FPORT_FDES (sock); - src = scm_to_locale_stringn (message, &len); + len = scm_i_string_length (message); + message = scm_i_string_start_writing (message); + src = scm_i_string_writable_chars (message); SCM_SYSCALL (rv = send (fd, src, len, flg)); - free (src); + scm_i_string_stop_writing (); if (rv == -1) SCM_SYSERROR; |