Re: asyncnet and reading from multiple socks
Issue I'm seeming to have is timeout never occurs upon false connections. the main point is to grab the ssh version. import asyncnet, asyncdispatch, strutils, random var serVer: string port = "22" output = "" proc genAddr(): string = randomize() var ip0 = rand(1..255) ip1 = rand(255) ip2 = rand(255) ip3 = rand(255) return (join([$ip0, $ip1, $ip2, $ip3], ".")) proc main() {.async.} = var sock0 = newAsyncSocket() sock1 = newAsyncSocket() sock2 = newAsyncSocket() res0: string res1: string res2: string host0 = genAddr() host1 = genAddr() host2 = genAddr() echo "Trying: " & host0 await sock0.connect(host0, Port(22)) echo "Trying: " & host1 await sock1.connect(host1, Port(22)) echo "Trying: " & host2 await sock2.connect(host2, Port(22)) res0 = await sock0.recvLine() res1 = await sock1.recvLine() res2 = await sock2.recvLine() echo res0 echo res1 echo res2 waitFor main() Run '''
Re: asyncnet and reading from multiple socks
Appreciate your response, I'll try to implement this and see if I can get a working sample to show.
Re: asyncnet and reading from multiple socks
[https://github.com/treeform/ws/blob/master/tests/sender_3.nim](https://github.com/treeform/ws/blob/master/tests/sender_3.nim) import ws, asyncdispatch, asynchttpserver, httpclient # Create three sockets and read from each of them asynchronously var numOpenWs = 0 proc doStuff(ws: WebSocket, idx: int, msg: string) {.async.} = inc numOpenWs await ws.send(msg) echo idx, ": ", await ws.receiveStrPacket() ws.close() dec numOpenWs proc main() {.async.} = var ws1 = await newWebSocket("wss://echo.websocket.org") ws2 = await newWebSocket("wss://echo.websocket.org") ws3 = await newWebSocket("wss://echo.websocket.org") echo "all sockets opened" asyncCheck ws1.doStuff(1, "you are first") asyncCheck ws2.doStuff(2, "you are second") asyncCheck ws3.doStuff(3, "you are third") echo "now just waiting for all sockets to close" while numOpenWs > 0: await sleepAsync(10) waitFor main() Run
Re: Marvin Minsky frame model /extended with ordered storage/
IMO, those links are too theoretical and you most probably need domain knowledge and actual use cases to know the best data structures to represent Frames. Looking around you can probably re-use OO techniques though: [https://en.wikipedia.org/wiki/Frame_language#Comparison_of_frames_and_objects](https://en.wikipedia.org/wiki/Frame_language#Comparison_of_frames_and_objects). Couple of notes: * Your proposal will be bottlenecked by string processing, at least `typ` should be an enum * `ptr Frame` should be just Frame as Frame is a ref object. * I don't know the associated procs/use-cases but all those heap allocations will lead to memory fragmentation, bad memory locality and poor performance if you need to create/destroy Frames in tight loop. * That Frames theory seems to heavily suffer from the [curse of dimensionality](https://en.wikipedia.org/wiki/Curse_of_dimensionality) My advice to go forward: * define what a minimal proof-of-concept should be able to do * implement it * refine the base data structure so that building that use-case from that data structure is easy. * add new use-cases, rinse-and-repeat. Check performance from time to time on non-toy inputs.
asyncnet and reading from multiple socks
I've attempted several approaches with this including trying to mix threads and async. what would be the best way to say send connect three sockets and read from each of the asynchronously?
Marvin Minsky frame model /extended with ordered storage/
* [https://en.wikipedia.org/wiki/Frame_(artificial_intelligence](https://en.wikipedia.org/wiki/Frame_\(artificial_intelligence)) * [https://web.media.mit.edu/~minsky/papers/Frames/frames.html](https://web.media.mit.edu/~minsky/papers/Frames/frames.html) What is the right code for implementing the class hierarchy of frames? I look at the base Frame class as a universal data (and code) type, can hold both single scalar values, and nested elements, all of them can be attributed by arbitrary slots. Making oriented graphs of such nodes with types inherited from the base Frame, we can model any type of data. Some subset of frames can be treated as executable so we can implement a homoiconic computing system. type Frame = ref object of RootObj typ: string val: string slot: Table[string,ptr Frame] nest: seq[ptr Frame] let nst = Frame(val:"nested") let hello = Frame(typ:"hello",val:"world",nest:@[nst]) echo hello[] Run
Re: rumpkernel or baremetal runtime to run Nim program standalone
Disabling GC and threads looks like a crutch. It is very strange not to use any achievements of the last twenty years in OS construction, as most of them available for free in source code. Maybe will something like FreeRTOS be great as a base for OS written in Nim?
Re: rumpkernel or baremetal runtime to run Nim program standalone
If you disable the garbage collector and does some tweaks Nim is able to run on microcontrollers such as an Arduino or Attiny85. So it's definitely possible to run bare metal. There has even been an OS demonstrator written in Nim: [https://github.com/dom96/nimkernel](https://github.com/dom96/nimkernel)
Re: Nim + Flutter == bright future?
Flutter + Dart = bright future ([https://www.cleveroad.com/blog/flutter-ui-framework](https://www.cleveroad.com/blog/flutter-ui-framework)) But Flutter + Nim ... I don't think so
Re: Is it possible to tune C output to be truly human readable?
I think the main issue would be the use of gotos :P