<-- back to the mailing list

A simple/toy client in C

Omar Polo op at omarpolo.com

Tue Sep 21 16:51:15 BST 2021

- - - - - - - - - - - - - - - - - - - 

stack at tilde.club writes:

I've been trying to put together a very simple C toy client - just
enought to connect to a Gemini server and get a page (no UI). My goal
is to figure out how a client connects, wrap a Common Lisp CFFI and
make a Common Lisp client (which is why C is a requirement).

My common lisp knowledge is pretty limited, but there's a reason youcan't use cl+ssl? AFAIK it should works. I know there are at least oneserver (which I forgot the name, sorry) and a client (tinmop) which arewritten entirely in common lisp.

I am using BearSSL (for its minimalism). I started with the sample
provided, modified for the Gemini request. I keep getting stuck with
error 62 (probably because I don't understand how to deal with TLS).
I attempted to generate the CA boilerplate code, but there are some
ominous hints that the code is HTTPS-specific.
Could someone point me in the right direction (Ideally, to a repo with
a C example :) I am not married to BearSSL - it just seemed an OK
starting point.

I've never used anything else beside libtls, so I can't comment (orcompare it to) other libraries, but I'm quite fond of it. It's reallywell-documented (well, it's from OpenBSD after all :P) and really niceto use.

As part of the regress suite of gmid (a gemini server) I've wrote areally simple gemini client which should fits your criteria:

https://git.omarpolo.com/gmid/tree/regress/gg.c

It's mean to be compiled as part of gmid, but it's really easy toextract (just define GEMINI_URL_LEN and replace strlcat/strlcpy or addlibbsd as deps)

Cheers!

Many thanks.