<< 18-05-2019 >>

00:00:56*laaron quit (Quit: ZNC 1.7.1 - https://znc.in)
00:03:29*rnrwashere quit (Remote host closed the connection)
00:05:44*laaron joined #nim
00:08:10*rnrwashere joined #nim
00:09:25*cyberjpn joined #nim
00:12:23skrylar[m]`Returns 1 if the computer is on. If the computer isn't on, the value returned by this function is undefined.
00:20:59*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
00:37:52FromGitter<gogolxdong> Nim has to compile to machine code on RISC-V.
00:41:47*laaron quit (Remote host closed the connection)
00:42:09*laaron joined #nim
01:34:51skrylar[m]i have a nagging feeling that people are going to hate any gui kit that isn't just qt
01:49:38*dddddd quit (Ping timeout: 245 seconds)
01:50:43*vlad1777d quit (Ping timeout: 246 seconds)
02:01:36*banc quit (Quit: Bye)
02:04:31*kapilp joined #nim
02:15:52leorize[m]skrylar: there's also `is_computer_on_fire()`
02:18:18FromDiscord<treeform> Wait ppl hate qt too.
02:23:07*banc joined #nim
02:27:07FromDiscord<DeltaPHC> People dislike pretty much all GUI toolkits for one reason for another. lol
02:30:45FromDiscord<DeltaPHC> Doesn't look 'native' (GTK; and has questionable meaning on Windows and Linux), uses too much resources (Electron), is quite heavyweight (Qt), too simple/primitive (libui), made for games (immediate mode libraries), isn't cross-platform (Win32/WinForms/WPF/UWP/Cocoa/etc)
02:31:39FromDiscord<DeltaPHC> 'questionable meaning' referring to 'native'
02:35:25FromDiscord<DeltaPHC> IMO, a true cross-platform GUI that can be everything to everyone is more of a pipe dream. Like a version of utopia that we're always trying to reach but can never get it quite right
02:43:24shashlickPartly why I've just used winapi directly on windows for feud
02:44:02shashlickBut as I enhance it, it gets more boring to think about support on other os
02:59:07*leorize quit (Quit: WeeChat 2.3)
03:04:03*dddddd joined #nim
03:05:25*leorize joined #nim
03:13:53*elronnd joined #nim
03:14:37*elronnd is now known as Elronnd
03:22:41*theelous3 quit (Ping timeout: 252 seconds)
03:29:04FromDiscord<kiwi> Question for @PMunch: I spent the morning working away with wxnim. Looking good up until I decided to change the colour of my buttons using setBackgroundColour. I couldn't find any working versions of wxColor or WxColor or wxColour or WxColour. Any thoughts please?
03:33:44FromGitter<Varriount> Shashlick: What's Feud?
03:34:34shashlickit's the text editor i've been working on - runs on windows, built with nim, scintilla, and winapi
03:34:39shashlickhttps://github.com/genotrance/feud
03:47:55*sealmove quit (Quit: WeeChat 2.4)
03:54:51*cyberjpn quit (Ping timeout: 246 seconds)
04:21:16skrylar[m]when i was making my own in go once, i went all the way in to left field. basically a Self-like tree of morphs, except things were assigned implementation on context, so there was no such things as a "menu." if you put a button inside a button, it made it a drop-down, if you put buttons inside a window, it became the menu, and submenus, and whatnot, so the actual UX code was purely semantic
04:21:39skrylar[m]it became a menu or a tool bar or a button or whatever based on where it was
04:22:19skrylar[m]the internals for that were... a bit strange
04:42:24skrylar[m]@varriount how did your stuff with SOAP and GUIs go?
05:12:27*dddddd quit (Remote host closed the connection)
05:16:57*cyberjpn joined #nim
05:31:18*kapilp quit (Quit: Connection closed for inactivity)
05:50:48FromDiscord<kiwi> Got it @PMunch - I can use constructwxColour to create the wxColours.
05:54:59*solitudesf joined #nim
06:01:53*narimiran joined #nim
06:09:44FromDiscord<kiwi> However you can't setBackgroundColour in linux so that seems to seal in Python with Qt5 as the more attractive option.
06:09:58FromDiscord<kiwi> However you can't setBackgroundColour for buttons in linux so that seems to seal in Python with Qt5 as the more attractive option.
06:18:21*solitudesf quit (Ping timeout: 246 seconds)
06:24:47*cyberjpn quit (Ping timeout: 258 seconds)
06:35:29*Vladar joined #nim
06:46:59*rnrwashere quit (Remote host closed the connection)
07:00:00*gmpreussner quit (Quit: kthxbye)
07:04:39*gmpreussner joined #nim
07:07:43*narimiran quit (Ping timeout: 258 seconds)
07:29:07FromDiscord<kiwi> However you can't setBackgroundColour for buttons in linux. I assume that's being true to the native gtk style, so that seems to seal in Python with Qt5 as the more attractive option. Thats a shame because I'd like to have migrated it to Nim.
07:29:34FromDiscord<kiwi> However you can't setBackgroundColour for buttons in linux. Foreground changes the text, background seems to be nothing. I assume that's being true to the native gtk style, so that seems to seal in Python with Qt5 as the more attractive option. Thats a shame because I'd like to have migrated it to Nim.
07:33:04*xet7 joined #nim
07:37:44*clyybber joined #nim
07:47:06*enigmeta quit (Quit: Connection closed for inactivity)
07:58:21*Trustable joined #nim
08:04:26skrylar[m]there are advantages to drawing widgets yourself :/
08:04:40skrylar[m]although doesn't Qt also spend an exorbinant amount of effort... trying to recreate what the platform already does
08:24:59*cyberjpn joined #nim
08:32:27*leorize quit (Ping timeout: 256 seconds)
08:40:42FromDiscord<kiwi> I have seen that written elsewhere, skrylar, but why should QT's implementation cost many more cycles (per unit quality) than a system version.
08:44:25skrylar[m]i'm thinking here the code effort to ex. get the native theming interface to draw the button, then also interface with the IME services if you're dealing with asian languages, and so forth
08:44:50skrylar[m]performance-wise qt didn't seem to have troubles (although sig/slot is going to be less efficient by a tiny margin, doesn't seem to have mattered)
08:45:45skrylar[m]also to make sure you get the border sizes correct because you can't always ask what those are, you just sort ofh ave to tweak it and pray, and then also deal with dpi scaling if that happens (LOT of programs surprisingly break when dpi scaling was turned on)
08:46:35skrylar[m]this reminds me that one thing i do need to pilfer from the vcl is the auto-size property for labels
08:50:23*cyberjpn quit (Ping timeout: 244 seconds)
08:53:16*kapilp joined #nim
08:54:38*leorize joined #nim
09:08:38FromDiscord<SirHaswell> Why when I do this code, it only displays 1 instruction and not all of them? I know that tokens contains 12 Token objects when I did it https://hastebin.com/netuzifiqa.cs
09:18:47*nsf joined #nim
09:20:02leorizethe amount of return in the code is terrifying :p
09:20:37leorizefor display_function, there's a built-in result variable that you could re-use instead of making a new token variable
09:21:01leorizealso, seqs are now initialized by default
09:25:14FromDiscord<SirHaswell> I don't understand what's not working and you don't seem to say it in your message
09:28:19*vlad1777d joined #nim
09:41:31FromDiscord<SirHaswell> I search all over the internet and it drives me crazy
09:41:31FromDiscord<SirHaswell> how to know a tank is a space or not? I can't find how to convert a tank into a Rune
09:47:21FromGitter<alehander42> what is tank?
09:49:39*solitudesf joined #nim
09:58:23FromDiscord<SirHaswell> deepl ...
09:58:31FromDiscord<SirHaswell> not tank, char
10:01:29*nsf quit (Quit: WeeChat 2.4)
10:06:04FromGitter<alehander42> runeAt($c, 0) ?
10:06:24FromGitter<alehander42> or something maybe
10:06:39FromGitter<alehander42> do you really need an unicode string for this program
10:08:08FromDiscord<SirHaswell> I need to know exactly which tank is a space or not
10:09:01FromGitter<alehander42> but can't you compare it to ` ` directly
10:12:37*al_ joined #nim
10:29:22*Cold[m] joined #nim
10:31:15Cold[m]hello, guys, i wanted to ask something
10:40:46Zevvhi Cold[m], just ask
10:43:13*laaron- joined #nim
10:44:00Cold[m]so in the docs, it says that the quit proc doesn't collect garbage. is this true?
10:45:57Cold[m]because when i ran my app through valgrind, it says all the heap blocks were freed
10:46:25Cold[m]regardless if i called quit(QuitFailure)
10:46:45*laaron quit (Ping timeout: 256 seconds)
10:54:52*entus1ast joined #nim
10:55:22entus1astare you aware of a working async process implementation?
10:55:43*entus1ast is now known as enthus1ast
10:57:16FromGitter<jrfondren> working in what sense? you can spawn any process and then add a trigger to the event machine when it ends
10:57:51enthus1astthere was cheatfates implementation (in asynctools) but it seems abadonned
10:58:00FromGitter<jrfondren> https://nim-lang.github.io/Nim/asyncdispatch.html#addProcess%2Cint%2CCallback
10:58:06FromGitter<jrfondren> implementation of what?
10:58:31enthus1asthttps://github.com/cheatfate/asynctools/blob/master/asynctools/asyncproc.nim
10:58:42FromGitter<jrfondren> yeah, and what do you want from that?
10:59:11enthus1astthat it works withouth me patching it?
11:01:34enthus1asti'm working on a simple monitoring and command execution tool (imagine nagios + saltsack with nim) and for this i need to spawn processes (that could be long running) and asyncly report back to the monitoring server
11:04:10enthus1astand atm i do not see any async process implementation that is maintained, so i was wondering if someone has something
11:17:59*enthus1ast quit (Ping timeout: 256 seconds)
11:30:21*kapilp quit (Quit: Connection closed for inactivity)
11:34:36*jjido joined #nim
11:43:22*solitudesf quit (Remote host closed the connection)
11:43:43*solitudesf joined #nim
12:04:07*nsf joined #nim
12:05:22*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
12:09:16*rnrwashere joined #nim
12:10:04*dddddd joined #nim
12:13:47*rnrwashere quit (Ping timeout: 248 seconds)
12:17:43*jjido joined #nim
12:32:53*al_ quit (Quit: al_)
12:39:32federico3nagios and saltstack... urgh
12:43:31*cyberjpn joined #nim
12:56:47FromGitter<mratsim> @enthus1ast, asynctools as been superceded by Chronos
12:58:57FromGitter<mratsim> async processes are not there yet though, but it's planned
13:01:57*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
13:29:32*mal`` quit (Quit: Leaving)
13:34:54*mal`` joined #nim
13:39:13federico3is Chronos meant to be merged into the stdlib?
13:39:19*Snircle joined #nim
13:45:44*serialdev[m] left #nim ("User left")
13:47:10*clyybber quit (Quit: WeeChat 2.4)
14:05:54FromDiscord<SirHaswell> var inputWithoutSpace = input.match(re"\s+(?=([^\"]*\"[^\"]*\")*[^\"]*$)")`
14:05:54FromDiscord<SirHaswell>
14:05:54FromDiscord<SirHaswell> Why my blackslash not work ?
14:08:16FromGitter<mratsim> @federico3, for now no plan. I think it would require an RFC.
14:09:22FromGitter<mratsim> we try to keep the async APIs where we can but sometimes we have to depart from it.
14:10:06leorize@SirHaswell: because that's a string literal
14:10:14leorizeraw string literal*
14:10:25leorizeyou can't escape anything within
14:10:45leorizeuse triple quote to quote the string instead
14:11:13leorizere"""s+(?=([^"]*"[^"]*")*[^"]*$)"""
14:19:48FromDiscord<SirHaswell> https://regexr.com/4e7il it's working on but not working on Nim, i get : None[RegexMatch@
14:19:51FromDiscord<SirHaswell> https://regexr.com/4e7il it's working on but not working on Nim, i get : None[RegexMatch]
14:29:13*cyberjpn quit (Ping timeout: 245 seconds)
14:34:43*narimiran joined #nim
15:02:28FromDiscord<Anuke> How would I make a template that invokes a string parsing function at compile-time?
15:02:28FromDiscord<Anuke> I am attempting to make a template that converts %-strings to colors: as an example, `%"ff0000"` -> `Col(r: 255, g: 0, b:0)`, where Col is a simple RGB color class.
15:02:28FromDiscord<Anuke>
15:02:28FromDiscord<Anuke> Code:
15:02:29FromDiscord<Anuke> ```
15:02:29FromDiscord<Anuke> template `%`*(str: string): Col =
15:02:31FromDiscord<Anuke> Col(r: str[0..1].parseHexInt().uint8, g: str[2..3].parseHexInt().uint8, b: str[4..5].parseHexInt().uint8, a: 255)
15:02:33FromDiscord<Anuke> ```
15:02:34FromDiscord<Anuke>
15:02:37FromDiscord<Anuke> However, this gives me the error "attempting to call undeclared routine: 'parseHexInt'" on usage, although that proc is marked as `noSideEffect`. What am I doing wrong?
15:03:13FromGitter<liquid600pgm> are you importing strutils?
15:03:45FromDiscord<Anuke> Yes, and my IDE displays correct documentation for the `parseHexInt` proc when I hover over it
15:04:24FromDiscord<Anuke> Note that the error only occurs when using the template; when I convert it to a proc, it works fine
15:05:09FromGitter<liquid600pgm> are you sure you *need* to use a template here?
15:05:17FromGitter<liquid600pgm> if a proc can do the job, use it
15:05:29ZevvAnuke: it works for me? http://p.zevv.nl/?0b93
15:05:39FromGitter<liquid600pgm> it's probably a thing with modules
15:06:15FromDiscord<Anuke> oh, it probably is-- I don't have the `strutils` imported in the module I'm running the code in
15:06:26FromGitter<liquid600pgm> yeah, that's the problem
15:06:32FromDiscord<Anuke> interesting
15:06:34FromGitter<liquid600pgm> I was in the middle of writing this
15:06:44FromGitter<liquid600pgm> simply add `export toHexInt`
15:06:57FromGitter<liquid600pgm> should do the job
15:07:04ZevvparseHexInt :)
15:07:05FromGitter<liquid600pgm> parseHexInt*, I meant
15:07:37FromDiscord<Anuke> Alright, that works, thanks
15:07:51narimiranto repeat: "are you sure you *need* to use a template here?"
15:08:16*theelous3 joined #nim
15:08:50FromGitter<liquid600pgm> quote https://nim-lang.org/docs/nep1.html#introduction-coding-conventions
15:08:55FromGitter<liquid600pgm> `Use a proc when possible, only using the more powerful facilities of macros, templates, iterators, and converters when necessary.`
15:08:56FromDiscord<Anuke> honestly, I *don't*, but if I happen to have a hex color used when tinting a sprite in a render loop, wouldn't it be faster to use `Col(r, g, b)` instead of parsing it from a string each time?
15:09:37FromGitter<liquid600pgm> it probably will, but today's computers are so fast you won't notice a difference
15:09:45FromGitter<liquid600pgm> parsing a hex string isn't a resource-intensive task
15:10:18FromDiscord<Anuke> Would `str[0..1]` generate garbage?
15:10:19FromGitter<liquid600pgm> you still substitute the `%"ff0000"` with a Col() constructor
15:10:46FromGitter<liquid600pgm> a macro could be used here to "compile" the Col() constructor at compile-time, if you really care about performance
15:10:55ZevvAnuke: if you 'const' your colors the parsing will happen at compile time
15:11:01FromGitter<liquid600pgm> ^
15:11:10Zevvno macros needed
15:11:20Zevvjust a proc and put the output in a const
15:11:44Zevvrule #1: Only use templates if you can't do it with a proc. Rule #2: Only use macros when you can't do it with a template
15:14:16FromDiscord<Anuke> Would that mean replacing `core.clearColor = %"af8569"`
15:14:16FromDiscord<Anuke> with ```
15:14:16FromDiscord<Anuke> const cl = %"af8569"
15:14:16FromDiscord<Anuke> core.clearColor = cl
15:14:16FromDiscord<Anuke> ```
15:14:17FromDiscord<Anuke> ?
15:14:41FromDiscord<Anuke> or is this first statement implicitly computed at compile time as well?
15:15:18FromDiscord<Anuke> the first *example*, not statement, sorry
15:22:03FromGitter<liquid600pgm> I don't think performance would be that terrible if you didn't make it a const anyway, I bet you create a ton of vec2s in your program anyway and it doesn't negatively impact performance.
15:22:30FromGitter<liquid600pgm> but if you want some optimization, you can use memoization
15:22:42FromGitter<liquid600pgm> basically, you cache the result of your function
15:23:12FromGitter<liquid600pgm> and yes, I said *function* not *procedure* because memoization is only useful with *functions*
15:23:26FromGitter<liquid600pgm> and functions don't have side effects
15:23:51FromGitter<liquid600pgm> for a given input, they always give the same output no matter what
15:38:12FromGitter<mratsim> const are always computed at compile-time and the result is pasted at call sites
15:39:07FromGitter<mratsim> "let" and "var" are sometimes computed at compile-time by the Nim compiler, especially for numeric or bitwise operations. In any case gcc/clang will do constant propagation as well
15:49:35*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
15:58:07*vivus joined #nim
15:58:49vivusHello all. I initialized my table like so: mytable = newTable[string, my_str_sequence]()
15:59:29vivusI am looping through another object, is the following code valid: mytable[p.row[0]] = (p.row[2], []) ?
15:59:41vivus```mytable[p.row[0]] = (p.row[2], [])```
15:59:58narimiranwhat is `my_str_sequence`?
16:00:25narimiran`(p.row[2], [])` is a tuple of some value and an empty array?
16:02:36*stefanos82 joined #nim
16:04:27vivusnarimiran: var my_str_sequence: seq[string]
16:05:29narimiranthen maybe this is what you wanted? `mytable[p.row[0]] = @[p.row[2]]`
16:05:45*SenasOzys joined #nim
16:06:25narimiranbut a var cannot be put here: `newTable[string, my_str_sequence]`, you need a type
16:06:41narimirannewTable[string, seq[string]]
16:07:18*solitudesf quit (Remote host closed the connection)
16:07:32*solitudesf joined #nim
16:07:51vivusoh. What is the difference between saying "var =" and "let ..." ?
16:08:08narimiranno, var vs let is not a problem here
16:08:20vivusim trying to understand, cause that is what confused me first
16:08:26narimiranbut var is for variables (mutable stuff), while let is for immutable stuff
16:08:48vivusimmutable meaning I can't add to it?
16:09:13vivusI want to add to the table
16:09:22narimiranyes, you cannot add to it. see here for some explantion for var vs let: https://narimiran.github.io/nim-basics/#_naming_values
16:09:32narimiranyou need to have `var myTable` then
16:42:18*vivus quit (Remote host closed the connection)
16:52:55*SenasOzys quit (Ping timeout: 255 seconds)
16:55:32FromDiscord<SirHaswell> https://regexr.com/4e7il it's working on but not working on Nim, i get : None[RegexMatch] why ?
16:56:18narimiranSirHaswell show us you nim code please
16:56:20ZevvCan you post a complete example
16:59:34ZevvQ: Some experiments show that Nim passes proc parameters smaller then 24 bytes by copy, and passes by ref for anything bigger. Where does this magic number 24 come from?
16:59:45narimiran3*8
16:59:51narimiranand i'm not joking
17:00:27narimiran3x pointer size
17:00:53Zevvwhy 3?
17:01:08narimirannow that's a much harder question for me to answer....
17:01:28Zevv:)
17:02:13Zevvand also a basic question: why is the same mechamism not used when assigning let constant vars? How is that different from passign to a constant proc argument?
17:03:10Zevvwow, "let constant vars", that's a nice way of wording
17:03:18ZevvI mean 'let' variables.
17:03:32Zevvalso bad, because it's not a variable. But also not a const. How do you call that?!
17:06:49*nsf quit (Quit: WeeChat 2.4)
17:06:57Zevvwow, it's even "3 * floatSize"
17:12:52*coopernurse joined #nim
17:26:22*JustASlacker joined #nim
17:34:22*SenasOzys joined #nim
17:38:09FromGitter<dom96> So I guess we need to fork async tools?
17:38:12*SenasOzys quit (Read error: Connection reset by peer)
17:50:28*jjido joined #nim
17:51:09FromDiscord<treeform> I wrote this asyncPool thing that only lets N async chains to run at the same time. Is there such a thing already? Where is a good place to contribute such a thing?
17:52:49FromDiscord<treeform> Basically I have a 1000s of HTTP requests to make, but if I make to many it rate limits me. So I make 30 at a time only.
18:10:26FromGitter<singularperturbation> that sounds very useful :)
18:17:31*gangstacat quit (Ping timeout: 248 seconds)
18:21:49*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
18:21:52*gangstacat joined #nim
18:28:34*JustASlacker quit (Ping timeout: 246 seconds)
18:29:53*jjido joined #nim
18:31:18FromDiscord<treeform> thanks
18:32:43*narimiran quit (Read error: Connection reset by peer)
18:38:34*gangstacat quit (Quit: Ĝis!)
18:43:40*JustASlacker joined #nim
19:02:28dom96treeform: Make a Nimble package out of this for now
19:09:12*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
19:18:11Zevvnarimiran[m]: how do you generate the nim-basics pages?
19:19:37*Cthalupa quit (Ping timeout: 255 seconds)
19:22:08*theelous3 quit (Ping timeout: 245 seconds)
19:23:36*enthus1ast joined #nim
19:26:51enthus1astyeah mratsim i loosely follow status-im's code
19:26:52*laaron- quit (Remote host closed the connection)
19:30:16Zevvnarimiran[m]: nevermind, found the source!
19:32:31enthus1astfederico3 i know its urgh but, the concepts behind nagios and saltstack is interesting, when i used saltstack a few years ago i find myself fighting with their python agent which was super strange to build, package and distribute.
19:32:37*JustASlacker quit (Ping timeout: 246 seconds)
19:32:46*Cthalupa joined #nim
19:36:55dom96enthus1ast, please create a fork. I'll happily switch the URL
19:41:47*Cthalupa quit (Ping timeout: 248 seconds)
19:44:29*nsf joined #nim
19:46:41*Cthalupa joined #nim
19:53:47*vlad1777d quit (Ping timeout: 244 seconds)
20:05:24federico3enthus1ast: concepts... in nagios?
20:07:15enthus1astdom96: i can't support it, i do not understand it
20:08:22dom96I see :/
20:08:32*matic joined #nim
20:08:47dom96I depend on it, I guess I'll need to support it eventually
20:09:01maticHey guys, is there a way to set a timeout for net.recvFrom ?
20:09:08enthus1astfederico3: the basis: return code determines color of the message, stdout is visible as message in the manager
20:09:37enthus1astor lets say, i have not give it enough brain power
20:11:10enthus1astand the remote execution part of saltstack was working nice for me
20:14:23enthus1astmatic, maybe you could check non blocking sockets
20:14:34enthus1astbut then you have to poll
20:16:09maticenthus1ast: I'm creating a socket with this 'socket = newSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)', how do I make it non blocking?
20:16:32maticI don't have much experience with sockets.
20:18:06enthus1astsocket.getFd().setBlocking(false)
20:18:20enthus1astbut this creates other funny issues :)
20:19:25enthus1astthis means that when you read from a socket and no new data is there it fails instantly
20:21:42maticexcellent, thanks!
20:23:18enthus1astdom96: i would be happy if you would :)
20:24:48*stefanos82 quit (Remote host closed the connection)
20:29:28FromDiscord<treeform> dom96, I want to make an "asyncproc" module that could use async stuff to communicate with other process. It appears to be quite hard. I think you almost need to wrap each process you run in its own thread an then communicate with the main process where you emulate it being async. Have you looked into this?
20:30:08FromDiscord<treeform> enthus1ast, udp should already be non blocking?
20:30:47FromDiscord<treeform> this is what I do: https://github.com/treeform/netpipe/blob/master/src/netpipe.nim#L127
20:30:59FromDiscord<treeform> i guess you do need to call `reactor.socket.getFd().setBlocking(false)`
20:32:09FromDiscord<treeform> enthus1ast, so what if it fails? that's normal operation. https://github.com/treeform/netpipe/blob/master/src/netpipe.nim#L315
20:32:53enthus1astyes you must catch it, but then there are other issues mainly: how often do i poll? Should i consider polling again if there was something etc etc
20:33:05FromDiscord<treeform> that is what I do
20:33:14FromDiscord<treeform> i poll till i get exception or -1
20:33:20FromDiscord<treeform> well I guess I poll 1000 times
20:33:30FromDiscord<treeform> so I can read 1000 packets per tick...
20:34:16FromDiscord<treeform> checkout my library: https://github.com/treeform/netpipe maybe you can just use it directly
20:35:46*JustASlacker joined #nim
20:38:04federico3treeform: does netpipe provide congestion control and message priority?
20:38:51enthus1astif i would write upd code again i would consider asyncdispatch2 (its called chronos now?)
20:39:48FromDiscord<treeform> congestion control sort of (its not as good as TCP but probably enough)
20:39:59FromDiscord<treeform> "message priority" no
20:40:38dom96treeform: AFAIK asyncproc package does support that
20:41:09dom96enthus1ast, just use asyncdispatch, iirc it supports udp now
20:41:11FromDiscord<treeform> oh its part of asynctools
20:41:30enthus1astoh nice dom96 :)
20:42:08*JustASlacker quit (Ping timeout: 245 seconds)
20:42:12FromDiscord<treeform> why is this asynctools not part of nim std?
20:43:10*rnrwashere joined #nim
20:46:45*matic quit (Quit: Leaving)
20:59:21dom96no specific reason
21:04:08*gangstacat joined #nim
21:07:44FromGitter<liquid600pgm> https://termbin.com/5kzw
21:07:49FromGitter<liquid600pgm> I don't think this is supposed to happen
21:08:10FromGitter<liquid600pgm> is this a bug?
21:08:40FromGitter<liquid600pgm> basically, it allows anyone to skip privacy and access object fields directly
21:09:29FromGitter<liquid600pgm> the expected output should have a `set d` line, btw
21:13:54*rnrwashere quit (Remote host closed the connection)
21:15:10*rnrwashere joined #nim
21:21:14*uvegbot quit (Remote host closed the connection)
21:28:02FromGitter<jrfondren> Nim's a language with casts and pointers. It's going to also have skipped privacy.
21:28:28*uvegbot joined #nim
21:32:17*rnrwashere quit (Remote host closed the connection)
21:32:31*Kaivo quit (Ping timeout: 258 seconds)
21:33:15*ng0 joined #nim
21:34:39*Kaivo joined #nim
21:35:43*smitop joined #nim
21:36:55smitopI'm using `asyncnet`/`asyncdispatch` to run a basic HTTP server that always responds with a hardcoded response. When I use my computer's LAN IP to connect from an other computer on the network it works great, but I can't connect from the machine itself. Localhost, local IP, always get a connection refused error from Chrome. How do I fix this?
21:37:08FromGitter<liquid600pgm> yeah, but it's annoying since I need some extra work to be done on assignment
21:37:39*Trustable quit (Remote host closed the connection)
21:39:58FromGitter<jrfondren> @smitop, http://$ip/ works remotely but not locally? sounds like you have some weird security.
21:40:36FromGitter<jrfondren> try turning off selinux (forever) and then the firewall (temporarily)
21:41:04smitop@jrfondren yep
21:41:16smitopI've tried turning off windows firewall but that didn't do anything
21:41:21FromGitter<jrfondren> oh windows.
21:41:41FromGitter<jrfondren> I have no idea then, sorry.
21:43:05FromGitter<jrfondren> thing to confirm, though: 1) you can't connect locally on the same runs that you can connect locally? You're not restarting the server to do a local test, or something. ⏎ 2) this also happens with other browsers, like firefox or IE?
21:44:15*Kaivo quit (Quit: WeeChat 2.4)
21:45:14smitopIt doesn't work in firefox or chrome, but I justed tested using curl (in Windows Subsystem for Linux) and it works there
21:47:43smitopPowershell's Invoke-WebRequest can't get it either
21:48:19smitopIDK why the (emulated) Ubuntu shell can access it
21:48:28dom96huh, that's peculiar
21:48:54dom96Did you try going to http://$your-lan-ip on the machine that's running the HTTP server?
21:49:02*Kaivo joined #nim
21:50:19smitopYep, I'm going to `http://192.168.2.123:7920/` on my server machine, which fails, and the exact same URI on a separate laptop on the same network, which works
21:51:20FromGitter<jrfondren> turn off your anti-virus?
21:52:29shashlickIs it running on all interfaces?
21:53:12FromGitter<jrfondren> he's connecting to the IP though.
21:55:19rayman22201sounds like @smitop isn't listening on the loopback interface. WSL works because it's basically a VM, which acts like a separate machine on the network.
21:55:42dom96Is that what smitop is using? WSL?
21:56:00dom96If so, there is no need for this
21:56:10smitopI'm running the server on real Windows
21:56:17rayman22201He said that he tested by using curl through WSL
21:56:18smitopAnd testing via `curl` on WSL
21:57:21*solitudesf quit (Quit: Leaving)
21:58:32rayman22201can you show your asyncnet connect code?
22:04:41smitophttps://www.irccloud.com/pastebin/7HPgWaud/
22:05:22smitopOh and `import asyncdispatch, asyncnet`, forget to copy that
22:05:38*theelous3 joined #nim
22:06:59dom96also, oh, I guess you're the sminot I follow on Twitter. I knew your nickname sounded familiar :)
22:07:39dom96You can try: server.socket.bindAddr(port, "localhost")
22:07:42dom96See if that makes a difference
22:09:11rayman22201you keep sniping me Dom lol
22:09:31rayman22201I type too slow :-P
22:10:23rayman22201you could also try `server.socket.bindAddr(port, "0.0.0.0")`
22:10:44rayman22201It should be doing that automatically as the default, but maybe it's not for some reason?
22:13:17smitopStill get the same issue
22:13:39smitopbtw I'm not that guy you follow on Twitter
22:16:31rayman22201try one more: `server.socket.bindAddr(port, "127.0.0.1")`
22:18:53FromDiscord<treeform> smitop, some rouers lack the route back capability, so you can't route from your public IP to your public IP.
22:19:58rayman22201That shouldn't affect localhost @treeform
22:20:29FromDiscord<treeform> Yes that should not
22:21:44rayman22201the lan network interface works fine for him, it is the localhost interface that does not work.
22:21:48smitop127.0.0.1 stops it from working anywhere
22:22:50rayman22201hrmm. That's weird
22:23:31smitopI ran a server example for Node.js and it worked perfectly
22:24:05smitopSo it's probably not a weird bug with my router
22:25:12FromDiscord<treeform> Could it be that what you are sending back makes Firefox make it look like a connection issue?
22:25:24FromDiscord<treeform> While curl just takes it?
22:25:57FromDiscord<treeform> Invalid http header or something like thay
22:26:38FromGitter<dom96> Are you testing with the same OS/browser versions on your other PC?
22:26:48FromGitter<dom96> If not then what treeform says is likely
22:28:10rayman22201What version of Nim are you using @smiltop?
22:28:50smitopBoth are on recent Chrome, Nim v0.19.6 (c6f601d4)
22:29:11rayman22201I just compiled your snippet to repro on devel, and I need to change the line to: `server.socket.bindAddr(Port(port))` or it wont compile
22:29:49rayman22201also, I get a "connection reset" error in firefox and chrome, which indeed means a bad header.
22:30:36smitopI just transcribed it wrong, in my actual code I use a compile-time var there
22:31:57smitopHow is it sending invalid data to localhost, but valid data to other computers on the LAN?
22:32:07smitopvalid/invalid HTTP data that is
22:32:52rayman22201The connection is getting closed for some reason
22:33:46rayman22201I can actually repro
22:34:29rayman22201connection gets closed on localhost, but my linux VM works
22:35:26rayman22201I actually think this might be a windows bug in the Nim network code
22:41:00*Jjp137 quit (Read error: Connection reset by peer)
22:41:45*Jjp137 joined #nim
22:48:00enthus1astsmitop try to receive before you send
22:50:06smitopenthus1ast: Thanks, that worked
22:50:24smitop`discard await clientSocket.recv(0)` is what I did
22:50:46smitop`asyncnet` should do that automatically tho if sending
22:53:01FromGitter<dom96> Why should it?
22:53:39rayman22201Please explain @enthus1ast? Why do you need to receive before you send?
22:53:59smitop@dom96 Because otherwise `asyncnet` is broken on Windows. IDK why it fixes the problem, but it does.
22:54:22smitopAlthough it does require the client to send some data over the wire first, which is bad
22:54:38smitopPerhaps fixing the root issue would also work
22:55:41rayman22201My intuition is telling me that the wrong flags are being given to the Windows bind syscall...
22:55:46enthus1astidk rayman22201 :/
22:56:54rayman22201you say Node works?
22:57:42smitop@rayman22201 Yep, I ran a basic node.js server and it worked right
22:57:43FromGitter<dom96> You should possibly use asynchttpserver of you don't want to deal with these details
22:58:17rayman22201@dom96 that sidesteps the issue doesn't it? it still seems like a bug
22:58:32*rnrwashere joined #nim
22:59:18smitopMy intention isn't to re-implement http, I'm just using some basic http to test my server. Later I intend to implement a custom protocol
22:59:58enthus1astbtw i run that code on linux and 1/3 of the refreshes showed error messages
23:00:03enthus1astthe other ran through
23:00:05enthus1astothers
23:00:16smitopBut the "receive before you send" limitation should definitely be documented
23:00:29rayman22201also, looking at the src for asynchttpserver, it has the same bug. That wouldn't have fixed anything, and would have just made it harder to see that there was a bug.
23:02:27enthus1astand i see that chrome does: 1. "GET / HTTP/1.1" 2. "GET /favicon.ico HTTP/1.1" maybe favicon this is part of the issue
23:02:56smitopI tested with curl, which doesn't request favicon, and got the same results
23:02:59*rnrwashere quit (Ping timeout: 258 seconds)
23:03:11*nsf quit (Quit: WeeChat 2.4)
23:04:06FromGitter<dom96> This is how sockets work. You can't just not read data and expect the OS to discard it.
23:04:37FromGitter<dom96> Asynchttpserver doesn't have the same issue, not sure why you think that
23:05:14smitop@dom96 But when I connect from a non-localhost computer, the OS *does* discard the data for me
23:05:39enthus1astshould it not be still in your input buffer?
23:06:37FromGitter<dom96> So then that's a Windows bug
23:07:02FromGitter<dom96> It shouldn't give different behaviour like that
23:07:25FromGitter<dom96> Either that or the behaviour can be explained by different browser versions or configuration
23:08:36rayman22201ok. I applogize @Dom96. aysnhttpserver does not have the issue.
23:08:39rayman22201Why?
23:09:04smitop@rayman22201 aysnhttpserver will always read before sending data
23:09:17FromGitter<dom96> Anyway. If you'd like, make an issue and we can discuss it
23:09:47FromGitter<dom96> It's an interesting edge case, but imo you're abusing the socket API here
23:10:04FromGitter<dom96> 'night
23:10:15rayman22201I see
23:10:22rayman22201night
23:10:25enthus1astn8
23:11:54rayman22201There are protocols that send before reading, like ssh and POP, so it still seems weird
23:12:28enthus1astrayman22201: test this with nc (ncat, socat) not with the browser
23:13:45enthus1astyou definitely can send before you read
23:14:51rayman22201I know you can in general. I mean using the Nim socket api with the loopback address on Windows.
23:16:11rayman22201That's my point. Why is Nim acting unexpectedly in this regard?
23:16:31enthus1astis it? Maybe its the browser?
23:16:43rayman22201Also, it's a counter point to Dom saying that this is an "abuse" of the socket api
23:17:31rayman22201actually. let me test something
23:18:57enthus1asthttps://gist.github.com/enthus1ast/19a472de473e1049ec954f9cc946068c
23:19:11enthus1astworks as expected
23:21:49enthus1astah
23:21:54enthus1astmaybe not
23:22:15enthus1astecho "foo" | ncat 127.0.0.1 7920
23:22:25enthus1astthis indeed resets the connection
23:23:01enthus1astthis i cannot explain :)
23:23:57enthus1astmhh
23:25:12smitopmaybe it's that browsers don't like getting a response before they send data, and when sending over LAN it added enough lag time that browsers sent data (that was ignored) before they got a response
23:25:13rayman22201wireshark shows the response. And then a RST packet
23:25:39rayman22201and powershell uses a httpclient, so I think it's just http that wants a read first
23:25:43rayman22201which makes sense
23:26:20rayman22201so it's not an abuse of sockets at all, it's just an abuse of HTTP :-P
23:27:11rayman22201well that was a fun dive down the network protocol rabbit hole :/
23:41:13*rnrwashere joined #nim
23:42:14*rnrwashere quit (Client Quit)
23:43:08*rnrwashere joined #nim