ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
ur5us has joined #crystal-lang
ur5us has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
jmdaemon has joined #crystal-lang
jmdaemon has quit [Client Quit]
jmdaemon has joined #crystal-lang
ur5us has quit [Ping timeout: 255 seconds]
ur5us has joined #crystal-lang
Sankalp- has joined #crystal-lang
Sankalp has quit [Ping timeout: 260 seconds]
Sankalp- is now known as Sankalp
ur5us has quit [Ping timeout: 255 seconds]
jmd_ has joined #crystal-lang
jmdaemon has quit [Ping timeout: 260 seconds]
jmd_ has quit [Ping timeout: 268 seconds]
jmdaemon has joined #crystal-lang
jmd_ has joined #crystal-lang
jmdaemon has quit [Ping timeout: 268 seconds]
jmdaemon has joined #crystal-lang
jmd_ has quit [Ping timeout: 260 seconds]
sagax has quit [Remote host closed the connection]
jmd_ has joined #crystal-lang
jmdaemon has quit [Ping timeout: 260 seconds]
jmdaemon has joined #crystal-lang
jmd_ has quit [Ping timeout: 252 seconds]
jmd_ has joined #crystal-lang
jmdaemon has quit [Ping timeout: 268 seconds]
jmd_ has quit [Ping timeout: 252 seconds]
jmdaemon has joined #crystal-lang
jmd_ has joined #crystal-lang
jmdaemon has quit [Ping timeout: 268 seconds]
jmd_ has quit [Ping timeout: 268 seconds]
jmdaemon has joined #crystal-lang
jmdaemon has quit [Ping timeout: 260 seconds]
jmdaemon has joined #crystal-lang
notzmv has joined #crystal-lang
jmd_ has joined #crystal-lang
jmdaemon has quit [Ping timeout: 252 seconds]
jmd_ has quit [Read error: Connection reset by peer]
jmdaemon has joined #crystal-lang
jmd_ has joined #crystal-lang
jmdaemon has quit [Ping timeout: 268 seconds]
notzmv has quit [Ping timeout: 268 seconds]
jmd_ has quit [Quit: ZNC 1.8.2 - https://znc.in]
<FromGitter> <636f7374> Hi everyone, I would like to ask a question about (C `socklen_t *restrict`). ⏎ Why doesn't `Pointer(LibC::SocklenT).new(sizeof(LibC::IfName).to_u32)` work? (return `-1`), but protected `Socket.system_getsockopt` works fine (return `0`). ⏎ What am I doing wrong? I'm a `rookie` in C language. :(.
notzmv has joined #crystal-lang
<FromGitter> <636f7374> 1) Works fine. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=630a5b037ccf6b6d45a19f6a]
<FromGitter> <636f7374> I feel that this is related to C `*restrict`, but it seems that `Crystal Docs` doesn't say how to deal with `*restrict`?, and I don't seem to find where is the `Socket.system_getsockopt` function?
<FromGitter> <636f7374> Also in WSL Ubuntu (only supports Ipv4 Ethernet), `Socket.new(Ipv6Address, blocking: false)` seems to cause program hangs, CPU 100%, I don't know if it's a Crystal problem or a WSL problem.
<yxhuvud> it is fully possible that crystal may lack some error checking and fail due to that. i'd report it to the github tracker.
<yxhuvud> btw, doing a Pointer.new and then not assigning it to a variable will never give anything useful back as the pointer only lives during the method call.
<yxhuvud> also, i think the error message says what is wrong, SYSPROTO_CONTROL is 2, so i think you have the argument order wrong.
<yxhuvud> (or at least, something has that)
<yxhuvud> or you might as well ignore everything I wrote. Hmm.
<yxhuvud> why do C so often have weird ways of calling stuff?
<FromGitter> <636f7374> @yxhuvud Thank you for your explanation, I am creating a TUN, and I thought it might be "argument order wrong" at first, but I wrote C bindings, and after testing, I found that it is related to `*restrict`, which made me deepen my affirmation of `*restrict`. ⏎ ⏎ 1) C.__getsockopt. ⏎ ⏎ ```cc -c lib_socket.c -o lib_socket.o ⏎ sudo crystal tun.cr``` ... [https:
<FromGitter> ... //gitter.im/crystal-lang/crystal?at=630a78d8999499629331b21d]
<yxhuvud> anyhow you can find the system_sockopt in src/crystal/unix/socket.cr
<FromGitter> <636f7374> 1) In Golang. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=630a79fbcf6cfd27af58828c]
<FromGitter> <636f7374> @yxhuvud Thanks for helping me find Socket.system_getsockopt. :)
<FromGitter> <636f7374> ```code paste, see link``` ⏎ ⏎ @yxhuvud Thank you for your help. :) [https://gitter.im/crystal-lang/crystal?at=630a7aedb16e8236e345e5e6]
<yxhuvud> That solved it? that make me wonder why it worked at all :)
<yxhuvud> (ie, why isn't it sending the pointer of the size in the base implementation)
<yxhuvud> oh, I was reading the setsockopt code. wtf.
<FromGitter> <636f7374> @yxhuvud 99% probably because I'm a rookie in C language 😣, 1% probably because I learned Crystal language from Ruby 😆.
<yxhuvud> nah, I'm also a rookie in C :/
<FromGitter> <636f7374> @yxhuvud 😋, Another problem I have is WSL subsystem (Ubuntu), TCPSocket.new Ipv6 blocking: false causes the program to get stuck (CPU 99%).
<FromGitter> <636f7374> 1) Crystal (test.cr) ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=630a7de5647d633cf6eb7c22]
<yxhuvud> my guess is that there is a errno check that isn't happening or is doing the wrong thing in some place.
<FromGitter> <636f7374> This question is very interesting, I was using ISP & Ethernet that supports Ipv6 for the past few months, the program has been working fine, I switched to another ISP & Ethernet (Ipv4 only) this week, and then this problem was triggered, I don't Know if it's a WSL problem or a Crystal problem.
xyhuvud has joined #crystal-lang
yxhuvud has quit [Ping timeout: 260 seconds]
<FromGitter> <636f7374> I put a lot of STDOUT.puts near the TCPSocket and found that the problem happens in `connect(addrinfo, timeout: connect_timeout)`. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=630a7fc6647d633cf6eb88b9]
<FromGitter> <636f7374> But `blocking: true`, Exception can be triggered normally. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=630a80359d3c186299cc97cf]
<FromGitter> <636f7374> In the end, I regret that I did not find the answer to the problem of Ipv6 stuck. It seems that this problem has also appeared in UserLAnd & Termux AArch64 (not sure), I can only let my friends test as many commands as possible, so that there will be more discoveries in the future. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=630a812e6837563d1ca0cd01]
<xyhuvud> I'd file an issue about it. Perhaps someone is able to replicate and figure it out
<xyhuvud> though actually. Does dtrace work on wsl?
<xyhuvud> argh. strace I mean. sorry.
<FromGitter> <636f7374> I don't know if it's Crystal's problem or WSL's problem, or what problem, so I didn't submit a Github Issue, strace doesn't seem to have any clues (just a bunch of libevent-related?), because WSL doesn't have perf programs installed so it doesn't print the call stack , which leaves me a bit at a loss, but triggers this issue every time, maybe in the future? 😳
<FromGitter> <636f7374> @xyhuvud :) Test environment requires WSL and an Ipv4-only Internet / Ethernet (The Carrier / ISP does not provide Ipv6).
<xyhuvud> if it is not one thing its the other. personally I have issues with some work related logins because my ipv6 is too good, so it tries to use ipv6 and fails.
<FromGitter> <636f7374> @xyhuvud Next time I try my best to let my friends install perf (it seems that WSL requires many steps to install perf) and strace information (I found only `libevent` information last time, I thought it was useless and deleted it), and I will `connect (addrinfo, timeout: connect_timeout)` inside put more `STDOUT.puts`.
<FromGitter> <636f7374> @xyhuvud Yes, Ipv6 is not very popular in some countries. 🥲
<FromGitter> <636f7374> @xyhuvud Cheapest ISP in my country, 5 years Broadband only cost less than 300USD, so probably no IPV6 and extremely low internet speed. 😓
sagax has joined #crystal-lang
<xyhuvud> If you are certain it is connect that fails, system_connect may be an interesting place to put output in btw. both verifying that arguments are sane, and what errno you get.
<xyhuvud> I have, uh, broadband as a part of my rent, but it represents something like $10 per month, for gigabit connection :)
<FromGitter> <636f7374> @xyhuvud Okay thanks for your answer, i will do more testing next time Ipv6 stuck problem and try if it can gdb & lldb, also without your help i might just use `system_getsockopt` and not be able to find the problem Also I think `Crystal Docs / Manual` should describe `*restrict`, which is tricky for Crystal users who are not good at C language.
hightower2 has joined #crystal-lang