IRC channel logs

2020-09-08.log

back to list of logs

***sajith_ is now known as nonzen
<dsmith-work>Tuesday Greetings, Guilers
<johnjay>dsmith-work: i think i asked this before but is guix the package system for guile?
<johnjay>i.e. the equivalent of melpa/apt/yum?
<dsmith-work>Well, I guess it looks like it's becoming that. But guix is actually a system package thingy. (never used guix)
<ardaukas>hello? :)
<ardaukas>I'm just new to scheme and Guile, just starting to try it ... because I'd like them to be my primary coding langs
<ardaukas>I hope that you can help me with some basic questions:
<ardaukas>- best web/forum (kind of stackoverflow) to ask questions about scheme/guile?
<dsmith-work>ardaukas: The mailing lists and here.
<ardaukas>- For my first network exercise I want to perform a DNS request to a specific name server, but can't find any library specific for DNS requests in Guile ... so I must be looking in the wrong place. Any suggestion for this use case?
<dsmith-work>The mailing lists are archived, and recently, this chan is now logged.
<ardaukas>I mean, I'd like to not make my "basic exercise" grow by having to implement it in C ;)
<ardaukas>I've tried "getaddrinfo" ... but does not seem to give the IP addresses nor I find any way to convert it's answer into an A IP value, for example
<catonano>ardaukas: I think you should get a connection to a dns server and then interrogate it in code you write yourself
<catonano>and then maybe you could just print the result in the repl
<catonano>as far as I can tell there are no libs for this but it shouldn't be very hard
<catonano>there are examples of tiny servers and clients in the manual
<ardaukas>there must be some lib, it's a basic network request
<dsmith-work>ardaukas: From your guile prompt, try (help getaddrinfo) Also https://www.gnu.org/software/guile/manual/html_node/Network-Databases.html
<ardaukas>as an example:
<ardaukas>(addrinfo:canonname (car (getaddrinfo "www.gnu.org" #f AI_CANONNAME)))
<ardaukas>$1 = "wildebeest.gnu.org"
<catonano>I used a little utility called "nc" to inspect the network traffic my guile script was generating, as an aid
<ardaukas>(guile-user)> (addrinfo:addr (car (getaddrinfo "www.gnu.org" #f AI_CANONNAME)))
<ardaukas>$2 = #(2 3509828756 0)
<ardaukas>... seems that could be a matter of converting that number to an IPv4 octet sequence?
<dsmith-work>ardaukas: Do you want it printbale in dotted quad notation?
<dsmith-work>So 3509828756 is #xd133bc94 is 209.51.188.148
<ardaukas>?? :O
<dsmith-work>You might want inet-ntop
<ardaukas>So it was there and just was missing the last step ?!
<dsmith-work>Ya. getaddrinfo returns things that are nice to pass to connect
<ardaukas>Juas! I had it there :) , just didn't think about "convert decimal to IP"
<dsmith-work>So that #(...) is a vector with the adress, address family, (and something else).
<ardaukas>great!
<ardaukas>oooook
<ardaukas>first time I use it (well, everything, scheme, guile ...) just had guessed that should be the one
<ardaukas>nice
<ardaukas>Thanks a lot! :)
<ardaukas>let me check inet-ntop
<dsmith-work>Well, it's just a fairly thin wrapper over the C getaddrinfo
<dsmith-work>As is inet-ntop
<ardaukas>I've seen it's a scheme function in POSIX->networking
<ardaukas>but guile complains saying it's an unbound variable
<ardaukas>In the docs there's no reference saying that an import is needed
<dsmith-work>scheme@(guile-user)> (addrinfo:addr (car (getaddrinfo "www.gnu.org")))
<dsmith-work>$1 = #(2 3509828756 0)
<dsmith-work>scheme@(guile-user)> (inet-ntop (sockaddr:fam $1) (sockaddr:addr $1))
<dsmith-work>$2 = "209.51.188.148"
<dsmith-work>That's from just starting guile.
<ardaukas>not my case:
<ardaukas>> $ guileGNU Guile 3.0.4
<dsmith-work>scheme@(guile-user)> (version)
<dsmith-work>$3 = "3.0.4"
<dsmith-work>Same
<ardaukas>?? exiting and retrying ... now it works !?!
<dsmith-work>Though I don't think you can use getaddrinfo to query a specific dns server. It just calls the local name resolver.
<ardaukas>can you check this in your side?:
<ardaukas>scheme@(guile-user)> (inet-ntoa 2130706433);;; <stdin>:5:0: warning: possibly unbound variable `inet-ntoa'ice-9/boot-9.scm:1669:16: In procedure raise-exception:Unbound variable: inet-ntoa
<ardaukas>scheme@(guile-user)> (inet-ntoa 2130706433);;; <stdin>:5:0: warning: possibly unbound variable `inet-ntoa'ice-9/boot-9.scm:1669:16: In procedure raise-exception:Unbound variable: inet-ntoa
<ardaukas>sorry for the formatting ... let me try
<ardaukas>scheme@(guile-user)> (inet-ntoa 2130706433)
<dsmith-work>It's inet-ntop not inet-ntoa
<dsmith-work>And you have to pass in the family, because it also does ipv6
<ardaukas>yes, yes, but attending to Guile's doc, inet-ntoa should perform the conversion:
<ardaukas> https://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Network-Address-Conversion.html#Network-Address-Conversion
<ardaukas>that line I've pasted is just an example from the doc
<dsmith-work>Note the "1.8" in that url?
<dsmith-work> https://www.gnu.org/software/guile/manual/html_node/Network-Address-Conversion.html is the 3.0.4 docs
<ardaukas>I was just about to tell you that the search engine had taken me to a wrong version :(
<ardaukas>have just realized of it
<ardaukas>and I agree with you that seems that getaddrinfo asks to the local system, no way to send the request to the remote DNS server (as "dig" does)
<dsmith-work>Yes, dig is a tool used specifcally for dns queries. getaddrinfo is for name resolution in general. (like it can use /etc/hosts or nfs or whatever is in nsswitch.conf. Well, suspect. Never tried..)
<ardaukas>yes, seems so. Thanks a lot, I'll check how launch dig from guile
<dsmith-work>dig -> (D)omain (I)nfo (G)roper
<dsmith-work>s/(and something else)/and port number
<catonano>ardaukas: sorry I misunderstood
<ardaukas>Thanks, you've been very helpful. Seems that there's nothing like GNU/Linux dig for scheme
<ardaukas>I'm just building the master branch of guile 3.0.4 for Ubuntu
<str1ngs>ardaukas: which variant of ubuntu are you using?
<str1ngs>focal should have guile 3.0.1
<str1ngs>in the repos I mean
<ardaukas>Ubuntu 20.04
<ardaukas>I've just checked /usr/bin/guile and it's 3.0.4 !
<str1ngs>:)
<ardaukas>curious, before I was lunching it from /usr/local/bin and was 3.0.1 ... there's something wrong
<str1ngs>guile --version is 3.0.1 for me. using focal 20.04
<ardaukas>yesterday I downloaded the 3.0.4 tar.gz and built and installed it ... and installed a 3.0.1 guile REPL ??
<str1ngs>lsb_release -a Description: Ubuntu 20.04.1 LTS
<str1ngs>ardaukas: did you install it with prefix /usr?
<ardaukas>no, just configure, make, sudo make install I think
<ardaukas>I'm checking it again
<str1ngs>maybe use make uninstall to remove /usr/local . make sure you still have the same configure prefix
<str1ngs>that's if you intend to use repo guile 3
<str1ngs>ardaukas: to remove the guile installed to /usr/local. bad wording on my part.
<dsmith-work>Try "type guile" from a bash shell
<ardaukas>yes, did it
<ardaukas>linked to /usr/local/bin/guile, which is 3.0.4.35...
<ardaukas>and /usr/bin/guile launches 3.4.35... too
<ardaukas>excuse me
<ardaukas>3.0.4.35... I mean
<ardaukas>Ubuntu 20.04.1 LTS
<ardaukas>well, no problem, nevertheless, I'll try building the very latest version and deploy it to /usr/local
<ardaukas>build fails. Tries to run "makeinfo" command, which is not found
<ardaukas>so, dependencies on flex an texinfo so far
<ardaukas>So, rebuilding now, thanks for your help :). I have to leave now, hope to be back soon
<dsmith-work>Often, "apt-get build-dep" for a previous version will install the dev packages you need.