@hecate I'll go out running, try to make the repo public and then come back to you.
@hecate too tired to finish this today, will poke you tomorrow once things are published.
@hecate So to summarise the problem I am currently stuck on:
As DHT protocol messages can easily become larger than the usual network MTU, messages can consist of multiple parts. Executing the desired request actions usually only makes sense after all parts have been successfully received and parsed, so I somehow need to manage the the acknowledgement, timeout and resend process of the message parts.
The basic idea is that each message part of a request is acknowledged by a response with ->
@hecate an empty payload. When either the request or the acknowledging response get lost, a part is not cleared from the set/ map of successfully sent-and-acked packets when the timeout kicks in, and should be sent again in the next attempt (if there are any left).
What makes the practical implementation rather tedious is
1. that sockets shall not be used in multiple threads concurrently (especially not having multiple threads blocking to receive on them)
2. that I only want to re-send the remaining un-acked parts from the previous attempt, so while System.Timeout.timeout returns a Nothing in case of timeout I still somehow need to get the remaining parts out for using them as input for the next attempt.
My current idea is to have a thread ->
@hecate receive and parse response packets until it gets terminated by a timeout, and put them into a TChan or TQueue for getting them out this thread.
I started trying to implement this here, https://git.orlives.de/schmittlauch/Hash2Pub/src/branch/dhtNetworking/src/Hash2Pub/DHTProtocol.hs#L217 but obviously none of the functions is finished yet, the types do not even match yet.
Also for sendAndAck it might make sense to manage the state with a State monad (transformer), but I don't fully get the interplay of StateT and IO yet.
Do you get my problem and have any ideas?
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!