• Moooom?!?!?! You should have told me earlier about THIS!!!

    From yeti@yeti@tilde.institute to tilde.institute on Tue Jan 23 07:54:02 2024
    -----------------------------------8<-----------------------------------
    $ cat s.scm
    (define p (open-tcp-client "news.tilde.club:119"))
    (display (read-line p)) (newline)
    $ ##
    $ ## interpreted:
    $ ##
    $ gsi s.scm
    200 news.tilde.club InterNetNews NNRP server INN 2.7.0 ready (no posting)
    $ ##
    $ ## compile:
    $ ##
    $ gsc -exe s
    $ ls -l s
    -rwxr-xr-x 1 yeti yeti 51404 Jan 23 06:59 s
    $ strip s
    $ ls -l s
    -rwxr-xr-x 1 yeti yeti 10148 Jan 23 06:59 s
    $ ##
    $ ## run:
    $ ##
    $ ./s
    200 news.tilde.club InterNetNews NNRP server INN 2.7.0 ready (no posting)
    $ █
    ----------------------------------->8-----------------------------------

    Maybe I really should play with a Scheme at least for a while.
    --
    I do not bite, I just want to play.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.institute on Tue Jan 23 14:13:07 2024
    I neither found `(do ...)` nor `(while ...)`, but that's not a
    showstopper for trying my standard bignum example:

    -----------------------------------8<-----------------------------------
    $ cat p.scm
    (let loop ((p 1) (pp 1))
    (set! p (+ p 1))
    (if (= (gcd pp p) 1)
    (begin
    (set! pp (* pp p))
    (print p " " pp "\n")))
    (if (< p 42)
    (loop p pp)))
    $ gsi p.scm
    2 2
    3 6
    5 30
    7 210
    11 2310
    13 30030
    17 510510
    19 9699690
    23 223092870
    29 6469693230
    31 200560490130
    37 7420738134810
    41 304250263527210
    $ gsc -exe p
    $ ./p
    2 2
    3 6
    5 30
    7 210
    11 2310
    13 30030
    17 510510
    19 9699690
    23 223092870
    29 6469693230
    31 200560490130
    37 7420738134810
    41 304250263527210
    $ █
    ----------------------------------->8-----------------------------------

    Having interpreter and compiler is nice.

    I tried Embeddable Common Lisp before and that was far more confusing to
    use.
    --
    R || 0 ... Resistance is futile.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.institute on Thu Jan 25 11:27:18 2024
    ------------------------------------------------------------------------ (define l "")

    (define p (open-tcp-client "news.tilde.club:119"))
    (set! l (read-line p))

    (display "ARTICLE <yay.scheme@87zfwwjzgd.xxx>\r\n" p) (force-output p)
    (set! l (read-line p))

    (let loop ()
    (set! l (read-line p))
    (if (not (string=? l ".\r")) ; read-line strips only the LF (of the CRLF)
    (begin
    (print l "\n") ; CR still in string :-/
    (loop)
    )
    )
    )

    (display "QUIT\r\n" p) (force-output p)
    (set! l (read-line p))

    (display ".\r\n" p) (force-output p)
    (set! l (read-line p))

    (exit)
    ------------------------------------------------------------------------

    Sometimes the simple tings take the most digging...
    --
    I do not bite, I just want to play.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.institute on Thu Jan 25 11:40:27 2024
    Apropos too simple things:

    ------------------------------------------------------------------------
    (print l "\n") ; CR still in string :-/ ------------------------------------------------------------------------

    The `:-/` was `:-(` earlier and that did screw up the highlighting of
    matching `()` in `mcedit`. So I could not make sense of my code
    indentation versus the editor's `()`-counting.

    Sometimes only partially smart is worse than dumb!

    I really should start using `emacsclient` for fast edits instead of
    `mcedit`.
    --
    I do not bite, I just want to play.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.institute on Thu Jan 25 13:40:36 2024
    More digging through the manual starts to pay back!
    Especially useful: `eol-encoding: 'cr-lf`
    Now I have no longer to manually handle CRLF.

    ------------------------------------------------------------------------ (define println-to-port-and-flush ; /!\ needs nicer name!
    (lambda (port string)
    (println port: port string)
    (force-output port)))

    (define l "")

    (define p
    (open-tcp-client
    (list address: "news.tilde.club" port-number: 119 eol-encoding: 'cr-lf))) (set! l (read-line p)) (println l)

    (println-to-port-and-flush p "ARTICLE <yay.scheme@88zfwwjzgd.xxx>")
    (set! l (read-line p)) (println l)

    (let loop ()
    (set! l (read-line p))
    (if (not (string=? l "."))
    (begin
    (println l)
    (loop)
    )
    )
    )

    (println-to-port-and-flush p "QUIT")
    (set! l (read-line p))

    (println-to-port-and-flush p ".")
    (set! l (read-line p))

    (exit)
    ------------------------------------------------------------------------
    --
    I do not bite, I just want to play.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.institute on Thu Jan 25 21:06:38 2024
    yeti <yeti@tilde.institute> writes:

    ------------------------------------------------------------------------ (define println-to-port-and-flush ; /!\ needs nicer name!
    (lambda (port string)
    (println port: port string)
    (force-output port))) ------------------------------------------------------------------------



    ------------------------------------------------------------------------ (define (println-to-port-and-flush port string)
    (println port: port string)
    (force-output port)) ------------------------------------------------------------------------
    --
    ( Are we there yet? )
    \ ( Be patient! )
    \ \
    _______________________ _@o ____________ _@o _@o _______________________
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.institute on Wed Jan 31 14:31:52 2024
    After a lot of Lisp/Scheme blues (every dialect seems to handle sockets
    in a different way) I remembered AWKA possibly having a FFI, so I could
    access sockets somehow. Surprise, surprise: AWKA handles sockets
    already like GAWK does.

    ------------------------------------------------------------------------
    $ cat nntp.awka
    BEGIN {
    s = "/inet/tcp/0/news.tilde.club/119"
    s |& getline
    print $0
    close(s)
    }
    $ awka -X -s -f nntp.awka
    $ ./awka-app.out
    200 news.tilde.club InterNetNews NNRP server INN 2.7.0 ready (no posting) ------------------------------------------------------------------------

    Couldn't be easier, eh?

    The size of the statically linked binary:

    ------------------------------------------------------------------------
    $ ls -l awka-app.out
    -rwxr-xr-x 1 yeti yeti 226576 Jan 31 13:33 awka-app.out
    $ strip awka-app.out
    $ ls -l awka-app.out
    -rwxr-xr-x 1 yeti yeti 205264 Jan 31 13:33 awka-app.out
    $ file awka-app.out
    awka-app.out: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=7fa82163c9518cab94989c4a2b69a456401d6d1f, for GNU/Linux 3.2.0, stripped
    ------------------------------------------------------------------------

    Dynamically linked:

    ------------------------------------------------------------------------
    $ awka -X -f nntp.awka
    $ ls -l awka-app.out
    -rwxr-xr-x 1 yeti yeti 17696 Jan 31 13:40 awka-app.out
    $ strip awka-app.out
    $ ls -l awka-app.out
    -rwxr-xr-x 1 yeti yeti 14536 Jan 31 13:40 awka-app.out ------------------------------------------------------------------------

    As well known AWK fan looking for a language that shall fit well into
    Nixens and interface nicely with C, AWKA really may be a candidate.
    --
    I do not bite, I just want to play.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.institute on Wed Jan 31 16:16:52 2024
    Well...

    ------------------------------------------------------------------------
    BEGIN {
    FS = "\r\n"
    OFS = "\r\n"

    s = "/inet/tcp/0/news.tilde.club/119"
    s |& getline

    print "article <87le85hatb.fsf@tilde.institute>" |& s
    s |& getline

    l=""
    while( l!=".\r" ) { s |& getline l ; print l }

    print "quit" |& s

    print "." |& s

    close(s)
    }
    ------------------------------------------------------------------------

    ...works with GAWK, bu not with AWKA and I'm currently not in the mood
    for a bug report.
    --
    I do not bite, I just want to play.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.institute on Wed Jan 31 16:21:07 2024
    Well...

    ------------------------------------------------------------------------
    BEGIN {
    FS = "\r\n"
    OFS = "\r\n"

    s = "/inet/tcp/0/news.tilde.club/119"
    s |& getline

    print "article <87le85hatb.fsf@tilde.institute>" |& s
    s |& getline

    l=""
    while( l!=".\r" ) { s |& getline l ; print l }

    print "quit" |& s

    print "." |& s

    close(s)
    }
    ------------------------------------------------------------------------

    ...works with GAWK, but not with AWKA and I'm currently not in the mood
    for a bug report.
    --
    I do not bite, I just want to play.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.institute on Thu Feb 1 17:35:34 2024
    Restart with v4.9.5...

    `define-syntax` finally works:

    ------------------------------------------------------------------------
    $ cat define-syntax.scm
    (define-syntax while
    (syntax-rules ()
    ((while test body ...)
    (let wloop ()
    (if test (begin body ... (wloop)))
    ))))

    (define i 0)
    (while (< i 10)
    (print i " ")
    (set! i (+ i 1))
    )
    (newline)
    $ gsi define-syntax.scm
    0 1 2 3 4 5 6 7 8 9 ------------------------------------------------------------------------
    --
    I do not bite, I just want to play.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.institute on Thu Feb 1 21:58:28 2024
    Gambit Scheme 4.9.5 allows easier switching of the C backend:

    ------------------------------------------------------------------------
    $ cat primorial.scm
    (let loop ((p 1) (pp 1))
    (set! p (+ p 1))
    (if (= (gcd pp p) 1)
    (begin
    (set! pp (* pp p))
    (print p " " pp "\n")))
    (if (< p 42)
    (loop p pp)))
    $ gsc -cc gcc -exe -o primorial.gcc primorial.scm
    $ ls -l primorial.gcc
    -rwxr-xr-x 1 yeti yeti 19288 Feb 1 21:11 primorial.gcc
    $ gsc -cc tcc -exe -o primorial.tcc primorial.scm
    $ ls -l primorial.tcc
    -rwxr-xr-x 1 yeti yeti 10960 Feb 1 21:12 primorial.tcc
    $ ./primorial.tcc
    2 2
    3 6
    5 30
    7 210
    11 2310
    13 30030
    17 510510
    19 9699690
    23 223092870
    29 6469693230
    31 200560490130
    37 7420738134810
    41 304250263527210 ------------------------------------------------------------------------

    \o/
    --
    I do not bite, I just want to play.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.institute on Sat Mar 23 00:21:08 2024
    ChickenScheme's wiki is much more blingblingy than Gambit's manual.

    <https://wiki.call-cc.org/man/5/Module%20(chicken%20tcp)>

    But the answers for my Gambit questions were easier to find in Gambit's
    less blingblingy manual.

    That 1st shot at sockets in Chicken took definitely longer than the same snippet in Gambit:

    ------------------------------------------------------------------------ (define l "")

    (import (chicken io) (chicken tcp))
    (define-values (nntp-in nntp-out) (tcp-connect "news.tilde.club" 119))
    (set! l (read-line nntp-in)) (print l)

    (write-line "ARTICLE <yay.scheme@88zfwwjzgd.xxx>" nntp-out)
    (set! l (read-line nntp-in)) (print l)

    (let loop ()
    (set! l (read-line nntp-in))
    (if (not (string=? l "."))
    (begin
    (print l)
    (loop))))

    (write-line "quit" nntp-out)
    (set! l (read-line nntp-in)) (print l)
    (write-line "." nntp-out)
    (set! l (read-line nntp-in)) (print l)
    (exit)
    ------------------------------------------------------------------------

    Not a beauty, just my 1st contact to Chicken.


    Scheme may have some standard(s), but the interesting stuff like sockets
    isn't covered in there. Gambit sockets yield readwrite ports, Chicken
    two ports.
    --
    If you know one Lisp/Scheme, you know one Lisp/Scheme.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From Patricia Ferreira@pferreira@example.com to tilde.institute on Sat Mar 23 06:25:00 2024
    yeti <yeti@tilde.institute> writes:

    ChickenScheme's wiki is much more blingblingy than Gambit's manual.

    <https://wiki.call-cc.org/man/5/Module%20(chicken%20tcp)>

    Omg, please translate ``blingblingy''. ``Shinning'', I say.

    That 1st shot at sockets in Chicken took definitely longer than the same snippet in Gambit:

    Compare it to C. :)

    Scheme may have some standard(s), but the interesting stuff like sockets isn't covered in there. Gambit sockets yield readwrite ports, Chicken
    two ports.

    --
    If you know one Lisp/Scheme, you know one Lisp/Scheme.

    Very true. Now, what's even more interesting is why I don't exchange
    Lisp for Scheme.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.institute on Sat Mar 23 12:22:54 2024
    Patricia Ferreira <pferreira@example.com> writes:

    yeti <yeti@tilde.institute> writes:

    That 1st shot at sockets in Chicken took definitely longer than the same
    snippet in Gambit:

    Compare it to C. :)

    I've a snippet that just spits out the NNTP server's welcome line, not a complete message (yet?). I'd like to have `defer` in C and easier/safer strings, but if I had to add reading a message via Message-ID, I'd not
    fall into panic.

    Unlike the dialect specific Scheme examples so far, the same C code
    passes different C compilers. That's what should be underlined with a
    flashy text marker.

    -----------------------------------8<----------------------------------- #include <sys/types.h>
    #include <sys/socket.h>
    #include <netdb.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <string.h>

    #define BUF_SIZE (4096)

    int main()
    {
    int sock;

    ssize_t nread;
    char buf[BUF_SIZE];

    struct addrinfo hints, *addrs;
    memset(&hints, 0, sizeof(struct addrinfo));
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;

    if (0 == getaddrinfo("news.tilde.club", "119", &hints, &addrs))
    {
    sock = socket(addrs->ai_family, addrs->ai_socktype, addrs->ai_protocol);
    if ( sock >= 0 )
    {
    if ( connect(sock, addrs->ai_addr, addrs->ai_addrlen) >= 0 )
    {
    /* Nothing to send, just read */
    nread = read(sock, buf, BUF_SIZE);
    if ( nread != -1)
    printf("Received %zd bytes: %s\n", nread, buf);
    else {
    perror("read");
    exit(EXIT_FAILURE);
    }

    }
    close(sock);
    }
    freeaddrinfo(addrs);
    }
    }
    ----------------------------------->8-----------------------------------
    ( Works with GCC, PCC and TinyCC )

    Very true. Now, what's even more interesting is why I don't exchange
    Lisp for Scheme.

    But from one Lisp to the next one, you'll probably not find things like
    sockets handled in a standard way too.

    Despite my frequent cursing about GCCisms breaking portable C code, for
    stuff you write yourself, portability in C still seems doable. OTOH,
    many huge projects like Emacs can't be compiled any more via compilers
    without GCCisms and I'm very angry[0] about this and call this GNU/GCC
    locked in syndrome ™Stallman's Revenge™.

    ____________

    0: <https://www.youtube.com/watch?v=XlVoD17y5y4&t=4s>
    --
    I do not bite, I just want to play.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From Patricia Ferreira@pferreira@example.com to tilde.institute on Sat Mar 23 09:26:16 2024
    yeti <yeti@tilde.institute> writes:

    Patricia Ferreira <pferreira@example.com> writes:

    yeti <yeti@tilde.institute> writes:

    That 1st shot at sockets in Chicken took definitely longer than the same >>> snippet in Gambit:

    Compare it to C. :)

    I've a snippet that just spits out the NNTP server's welcome line, not a complete message (yet?). I'd like to have `defer` in C and easier/safer strings, but if I had to add reading a message via Message-ID, I'd not
    fall into panic.

    Unlike the dialect specific Scheme examples so far, the same C code
    passes different C compilers. That's what should be underlined with a
    flashy text marker.

    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netdb.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <string.h>

    #define BUF_SIZE (4096)

    int main()
    {
    int sock;

    ssize_t nread;
    char buf[BUF_SIZE];

    struct addrinfo hints, *addrs;
    memset(&hints, 0, sizeof(struct addrinfo));
    hints.ai_family = AF_UNSPEC;

    I would say you should say AF_INET here. POSIX.1 only specifies
    AF_INET, AF_INET6, AF_UNIX. So your program is not POSIX.1 with
    AF_UNSPEC.

    hints.ai_socktype = SOCK_STREAM;

    if (0 == getaddrinfo("news.tilde.club", "119", &hints, &addrs))
    {
    sock = socket(addrs->ai_family, addrs->ai_socktype, addrs->ai_protocol);
    if ( sock >= 0 )
    {
    if ( connect(sock, addrs->ai_addr, addrs->ai_addrlen) >= 0 )
    {
    /* Nothing to send, just read */
    nread = read(sock, buf, BUF_SIZE);
    if ( nread != -1)
    printf("Received %zd bytes: %s\n", nread, buf);
    else {
    perror("read");
    exit(EXIT_FAILURE);
    }

    }
    close(sock);
    }
    freeaddrinfo(addrs);
    }
    }

    ( Works with GCC, PCC and TinyCC )

    Check all that bureaucracy! :-)

    Very true. Now, what's even more interesting is why I don't exchange
    Lisp for Scheme.

    But from one Lisp to the next one, you'll probably not find things like sockets handled in a standard way too.

    I had in mind things like error messages. SBCL's error messages are so
    nice, for example. And Scheme virtual machines tend to be horrible.

    Despite my frequent cursing about GCCisms breaking portable C code, for
    stuff you write yourself, portability in C still seems doable. OTOH,
    many huge projects like Emacs can't be compiled any more via compilers without GCCisms and I'm very angry[0] about this and call this GNU/GCC
    locked in syndrome ™Stallman's Revenge™.

    So far, nobody except friends have used my software. So to me writing
    portable code have only helped with my education, but I think it's been
    very much worth it. (For example, Writing portacle code is also a good exercise in abstraction.)

    In practice, I view portability as an easy way to adapt your software to another system. Having it compile and run perfectly in ``all systems''
    can only be achived with some specific types of programs if at all.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.institute on Sat Mar 23 18:07:00 2024
    Patricia Ferreira <pferreira@example.com> writes:

    yeti <yeti@tilde.institute> writes:

    Patricia Ferreira <pferreira@example.com> writes:

    yeti <yeti@tilde.institute> writes:

    struct addrinfo hints, *addrs;
    memset(&hints, 0, sizeof(struct addrinfo));
    hints.ai_family = AF_UNSPEC;

    I would say you should say AF_INET here. POSIX.1 only specifies
    AF_INET, AF_INET6, AF_UNIX. So your program is not POSIX.1 with
    AF_UNSPEC.

    ---<man 3 getaddrinfo>--------------------------------------------------
    ai_family

    This field specifies the desired address family for the
    returned addresses. Valid values for this field include
    AF_INET and AF_INET6. The value AF_UNSPEC indicates that
    getaddrinfo() should return socket addresses for any
    address family (either IPv4 or IPv6, for example) that can
    be used with node and service. ------------------------------------------------------------------------

    Sorry, I needed that IPv4/v6 tolerance.

    Check all that bureaucracy! :-)

    That allows plugging in more error checks in a way that fits the rest of
    the application than just using one fat monolithic call.

    For a quick throw away one liner I sure like it easier, e.g.:

    ---<manually \-wrapped for half a bit of readability>-------------------
    $ gawk 'BEGIN { \
    N="/inet/tcp/0/news.uni-stuttgart.de/119" ; N |& getline ; print \
    ; print "date" |& N ; N |& getline ; print \
    ; close(N) ; }'
    200 news.uni-stuttgart.de InterNetNews NNRP server INN 2.5.2 ready (no posting) 111 20240323164058
    $ # terminates, gives next prompt ------------------------------------------------------------------------

    Near to unbeatable for some quick and dirty throw away code. For
    standard AWK with some GAWKy extensions (e.g. that way of networking and coroutines), there's a compiler (AWKA), but unluckily original AWKA
    doesn't even build currently and a different fork which builds hangs
    after the NNTP welcome line and I sure wont start debugging foreign
    code.

    ---<manually \-wrapped for half a bit of readability>-------------------
    $ awka -x 'BEGIN { \
    N="/inet/tcp/0/news.uni-stuttgart.de/119" ; N |& getline ; print \
    ; print "date" |& N ; N |& getline ; print \
    ; close(N) ; }'
    200 news.uni-stuttgart.de InterNetNews NNRP server INN 2.5.2 ready (no posting) ------------------------------------------------------------------------

    But from one Lisp to the next one, you'll probably not find things
    like sockets handled in a standard way too.

    I had in mind things like error messages. SBCL's error messages are
    so nice, for example. And Scheme virtual machines tend to be
    horrible.

    Currently I'm looking at languages that compile to C. The mentioned
    Schemes (and AWKA, BACON, Nim) do.

    In practice, I view portability as an easy way to adapt your software
    to another system. Having it compile and run perfectly in ``all
    systems'' can only be achived with some specific types of programs if
    at all.

    I cannot check everything against GLIBC, MUSL, BSDCLIB, ... but I would
    not use stuff I already know to be problematic.

    But needing to handle sockets differently in every 2nd dialect of the
    *same* language adds a level of not portable that's just scary.

    I cursed about BASIC's and Pascal's diversity since TRS-80 and CP/M
    days, so that's not really a new problem. And not even to mention all
    those slightly incompatible assemblers for the same chip/CPU/ISA. Much
    time got wasted over decades with such questions.

    OTOH monopolies kill evolution.

    I need more caffeïne!
    --
    I do not bite, I just want to play.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.institute on Sat Mar 23 22:27:15 2024
    Net access in this a bit queer (old meaning!) BASIC dialect (being
    compiled to C) is very simple. When looking for a compiled alternative
    to AWK, I played with it a bit, but when I reported a problem, they
    slammed the door and that kind of killed all fun and trust. :-/

    ------------------------------------------------------------------------
    OPEN "paganini.bofh.team:119" FOR NETWORK AS nntp
    RECEIVE dat$ FROM nntp
    REM no print, add error check later

    SEND "ARTICLE <87wmvwubuz.fsf@tilde.institute>\r\n" TO nntp
    RECEIVE dat$ FROM nntp
    REM no print, add error check later

    REPEAT
    RECEIVE dat$ FROM nntp
    PRINT dat$;
    tail$ = RIGHT$(tail$ & dat$,4)
    UNTIL tail$ == "\n.\r\n"

    SEND "QUIT\r\n.\r\n" TO nntp
    REM no print, add error check later

    CLOSE NETWORK nntp ------------------------------------------------------------------------

    Shit happens, moving on.
    --
    I do not bite, I just want to play.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From Patricia Ferreira@pferreira@example.com to tilde.institute on Sat Mar 23 19:55:53 2024
    yeti <yeti@tilde.institute> writes:

    Patricia Ferreira <pferreira@example.com> writes:

    yeti <yeti@tilde.institute> writes:

    Patricia Ferreira <pferreira@example.com> writes:

    yeti <yeti@tilde.institute> writes:

    struct addrinfo hints, *addrs;
    memset(&hints, 0, sizeof(struct addrinfo));
    hints.ai_family = AF_UNSPEC;

    I would say you should say AF_INET here. POSIX.1 only specifies
    AF_INET, AF_INET6, AF_UNIX. So your program is not POSIX.1 with
    AF_UNSPEC.

    ---<man 3 getaddrinfo>--------------------------------------------------
    ai_family

    This field specifies the desired address family for the
    returned addresses. Valid values for this field include
    AF_INET and AF_INET6. The value AF_UNSPEC indicates that
    getaddrinfo() should return socket addresses for any
    address family (either IPv4 or IPv6, for example) that can
    be used with node and service. ------------------------------------------------------------------------

    Sorry, I needed that IPv4/v6 tolerance.

    I will ignore IPv6 until the whole world begins to use it. I might
    leave IPv6 as heritage to my kids. :-)

    Check all that bureaucracy! :-)

    That allows plugging in more error checks in a way that fits the rest of
    the application than just using one fat monolithic call.

    Of course. It's C programming.

    For a quick throw away one liner I sure like it easier, e.g.:

    ---<manually \-wrapped for half a bit of readability>-------------------
    $ gawk 'BEGIN { \
    N="/inet/tcp/0/news.uni-stuttgart.de/119" ; N |& getline ; print \
    ; print "date" |& N ; N |& getline ; print \
    ; close(N) ; }'
    200 news.uni-stuttgart.de InterNetNews NNRP server INN 2.5.2 ready (no posting)
    111 20240323164058
    $ # terminates, gives next prompt ------------------------------------------------------------------------

    Near to unbeatable for some quick and dirty throw away code.

    The UNIX way.

    OTOH monopolies kill evolution.

    That's true. And diversity creates problems. Such is life.
    --- Synchronet 3.19a-Linux NewsLink 1.113