guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hello! I'm guile newbie. getsockopt problem on OSX.


From: Mark H Weaver
Subject: Re: Hello! I'm guile newbie. getsockopt problem on OSX.
Date: Fri, 13 Nov 2015 11:48:33 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Park SungMin <address@hidden> writes:

> I used guile 2.0.11 on Mac OSX.
> but, I find this problem..
>
>
> (use-modules (system foreign)
>            (rnrs bytevectors))
>
> (define sock (socket AF_INET SOCK_DGRAM 0))
>
> (getsockopt sock SOL_SOCKET SO_SNDBUF) ;;=> 140733193397248 ???
>
>
> so…I use C function directly…
>
> ;;; 
> (define foreign-getsockopt
>   (pointer->procedure int (dynamic-func "getsockopt" (dynamic-link))
>                     (list int int int '* '*)))
>
> (define ret-value (sint-list->bytevector '(0) (native-endianness) 4))
> (define size-value (sint-list->bytevector '(4) (native-endianness) 4))
>
> (foreign-getsockopt (port->fdes sock) SOL_SOCKET SO_SNDBUF 
> (bytevector->pointer ret-value)
>                   (bytevector->pointer size-value))
>
> (bytevector->sint-list  ret-value (native-endianness) 4) ;;=> 9216. It's 
> right!
>
>
> is it bug of getsockopt??

Thanks for the report.  Note that address@hidden is the preferred
place to send bug reports.

It is indeed a bug, going back to 2001.  The code assumed that for the
SO_SNDBUF and SO_RCVBUF options, the argument was of type 'size_t', when
in fact both the Linux and POSIX documentation indicates that the
argument is of type 'int'.

Fixed in e94a42c7f05d4b816dcb62c139dd65291a11dd78, which will be in
2.0.12.

     Thanks!
       Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]