unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Hello! I'm guile newbie. getsockopt problem on OSX.
@ 2015-11-11 18:17 Park SungMin
  2015-11-12  9:46 ` tomas
  2015-11-13 16:48 ` Mark H Weaver
  0 siblings, 2 replies; 3+ messages in thread
From: Park SungMin @ 2015-11-11 18:17 UTC (permalink / raw)
  To: guile-user


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??





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Hello! I'm guile newbie. getsockopt problem on OSX.
  2015-11-11 18:17 Hello! I'm guile newbie. getsockopt problem on OSX Park SungMin
@ 2015-11-12  9:46 ` tomas
  2015-11-13 16:48 ` Mark H Weaver
  1 sibling, 0 replies; 3+ messages in thread
From: tomas @ 2015-11-12  9:46 UTC (permalink / raw)
  To: Park SungMin; +Cc: guile-user

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Nov 12, 2015 at 03:17:32AM +0900, Park SungMin wrote:
> 
> 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??

FWIW, on Linux (some Debian oldstable with stains of stable & testing, and a 3.2.0-3,
64 bit), I'm getting 229376, wich is the expected value (it corresponds exactly with
the value in /proc/sys/net/core/wmem_default).

Guile 2.0.11 here, too.

So perhaps it's something specific to the OSX port?

regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlZEYAsACgkQBcgs9XrR2kbtlwCfaCRlWG4D0rBCGZwf7XPywZez
GJ0An3/9pkzRY2vmiSlLcqFQxBp6aJXc
=YBbm
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Hello! I'm guile newbie. getsockopt problem on OSX.
  2015-11-11 18:17 Hello! I'm guile newbie. getsockopt problem on OSX Park SungMin
  2015-11-12  9:46 ` tomas
@ 2015-11-13 16:48 ` Mark H Weaver
  1 sibling, 0 replies; 3+ messages in thread
From: Mark H Weaver @ 2015-11-13 16:48 UTC (permalink / raw)
  To: Park SungMin; +Cc: guile-user

Park SungMin <byulparan_eng@icloud.com> 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 bug-guile@gnu.org 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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-13 16:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-11 18:17 Hello! I'm guile newbie. getsockopt problem on OSX Park SungMin
2015-11-12  9:46 ` tomas
2015-11-13 16:48 ` Mark H Weaver

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).