How do you buffer a Gemini connection?

almaember almaember at
Sun Mar 28 21:07:38 BST 2021


I'm planning on creating my own Gemini client (with C99 and OpenSSL, if
you want to know). However, I have a problem with how I should be
implementing the downloading part.

So, how should I be buffering a Gemini connection? Since there is no
size indicator, I can't be sure everything even fits into memory, or
how much time it's going to take to download, or if it's even going to
end at all.

Another problem is long-polling. Through my exploration of Geminispace,
I found a few capsules that used a hack to push live updates to the
client. Specifically, these servers didn't close the connection, but
instead kept it open and just sent new data when something happened.

Since the spec says nothing (or I'm blind) about buffering, so I want
to ask others about what I should be doing, while still being able to
actually parse the output.

My ideas as of right now:

 - Have a big buffer and store everything in it until the connection is
   closed. The connection would be terminated if:
    - the connection closes
    - the server didn't send anything for X seconds
 - Buffer by line and don't close the connection unless the user
   terminates it (by pressing the stop key or by loading another
   capsule). Compatible with long polling.

Thanks in advance for any help!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 659 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the Gemini mailing list