SMOLNET PORTAL home about changes

Bigger scheme - sam's capsule: sloum's small s-expression based language - network protocols

           /       \       /
    k --- a         b --- f
   /       \       /       \
           me --- l         i
   \       /       \       /
    j --- c         d --- e
           \       /
            g --- h


Ever wondered how many lines will it take to program basic network stuff in your programming language of choice?

I must admit it is disgustingly easy in slope ;-)

SMTP

; ensure LOGNAME and HOSTNAME are set and exported in shell before
; runnig the code!
(define Sender
    (string-append (env "LOGNAME") "@" (env "HOSTNAME")))
(define Recipient
    (string-append (env "LOGNAME") "@" (env "HOSTNAME")))

;(define Smtp (file-open-write "foobar"))
(define Smtp (net-conn "localhost" "25"))

(if Smtp
    (begin
        (write (string-append "HELO " (env "HOSTNAME") "\r\n") Smtp)
        (write (string-append "MAIL FROM: " Sender "\r\n") Smtp)
        (write (string-append "RCPT TO: " Recipient "\r\n") Smtp)
        (write "DATA\r\n" Smtp)
        (write "Subject: Hello from slope\r\n" Smtp)
        (write "\r\nHello from slope...\r\n" Smtp)
        (write "\r\n.\r\n" Smtp)
        (close Smtp))
    (display "Cannot connect."))


HTTP(S)

(if (define Http (net-conn "rawtext.club" 443 #t))
    (begin
        (display Http)
        (write "GET /index.html HTTP/1.0\nHost: rawtext.club\r\n\r\n" Http)
        (define Page (read-all-lines Http))
        (for-each (lambda (line) (display line)(newline)) Page)
        (close Http)))


Gemini

(if (define Gemini (net-conn "rawtext.club" 1965 #t))
    (begin
        (write "gemini://rawtext.club/\n" Gemini)
        (for-each (lambda (line) (begin (display line)(newline))) (read-all-lines Gemini))
        (close Gemini)))


See you then,
-- sam

Get slope

Gitea repository (https://git.rawtext.club)
Response: 20 (Success), text/gemini
Original URLgemini://rawtext.club/~samhunter/gemlog/2021-08-17-sloums...
Status Code20 (Success)
Content-Typetext/gemini; charset=utf-8; lang=en