Hello Guile users, I wrote some TCP server and client in Guile which I have uploaded here:
https://gitlab.com/zelphir-kaltstahl-projects/guile-scheme-tutorials-and-examples/raw/dev/network-programming/tcp-client.scm and here: https://gitlab.com/zelphir-kaltstahl-projects/guile-scheme-tutorials-and-examples/raw/dev/network-programming/tcp-server.scm or normal GitLab view: https://gitlab.com/zelphir-kaltstahl-projects/guile-scheme-tutorials-and-examples/tree/dev/network-programming (Is it OK to post these as links, or always better to include all relevant source code on the mailing list? On other e-mail lists I have experienced that my message was too long and got truncated, so I posted the code as links to the raw file on GitLab.) The loop for reacting on messages from a client on the server looks like this: (while #t (let* ([bytes-count (recv! in-out-sock receive-buffer)] [message-received (byte-vector->utf8-message receive-buffer bytes-count)]) (message-handler client-connection message-received)))))) But this has a problem: When I run both client and server in two terminals and then exit the client using Ctrl-D, the server somehow gets stuck in the loop always receiving the empty string. Since that is 0 Bytes long, it does not really take anything from the socket (if I understand correctly), but instead can recv! in the next iteration again immediately. The only thing that works then for stopping this loop is to hold down Ctrl-C on the server for a second or so. The same happens for the client receiving message loop, because that one also does not detect me suddenly interrupting or killing the server and then loops on the empty string. At first I thought if I caught eof-object? and then (break) the loop it would solve the problem, but apparently it does not. Basically I would like the server and client to be prepared for non proper shutdown of either. How can I handle / detect abrupt connection losses, so that I can break the message handling loop? On 20.06.2018 18:00, guile-user-requ...@gnu.org wrote: > Send guile-user mailing list submissions to > guile-user@gnu.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.gnu.org/mailman/listinfo/guile-user > or, via email, send a message with subject or body 'help' to > guile-user-requ...@gnu.org > > You can reach the person managing the list at > guile-user-ow...@gnu.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of guile-user digest..." > > > Today's Topics: > > 1. Re: lat? and atom? not in guile? (Thompson, David) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 20 Jun 2018 10:55:43 -0400 > From: "Thompson, David" <dthomps...@worcester.edu> > To: John Cowan <co...@ccil.org> > Cc: Joshua Branson <jbra...@fastmail.com>, Guile User > <guile-user@gnu.org> > Subject: Re: lat? and atom? not in guile? > Message-ID: > <CAJ=rwfzxx_ihgpvmij+nv0g6jrq2z-sozfjgobotqzs0q_j...@mail.gmail.com> > Content-Type: text/plain; charset="UTF-8" > > On Wed, Jun 20, 2018 at 10:40 AM, John Cowan <co...@ccil.org> wrote: >> On Wed, Jun 20, 2018 at 10:37 AM, Joshua Branson <jbra...@fastmail.com> >> wrote: >> >> >>> Oh hey David! Thanks for the explanation! Maybe I need to take another >>> look at that book then. I found it a little repetitive, but I am >>> probably not quite grasping some of the fundamentals. >>> >> It's meant to be repetitive. It's explicitly compared in the introduction >> to Hanon's finger exercises for the piano: C-E-F-G-A-G-F-E, >> D-F-G-A-B-A-G-F, E-G-A-B-C-B-A-D and so on forever, up the scale and down >> in every key. Boring as hell, but just the thing to get fluency into your >> fingers. > It's repetitive but honestly I found that the comedic writing made the > exercises very entertaining. I was rarely bored. I don't play the > piano, but I do play drums, and the equivalent to Hanon's finger > exercises is an old book called Stick Control, which is definitely in > the boring as hell category! I'm glad that Lisp beginners have > something more fun available. :) > > - Dave > > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > guile-user mailing list > guile-user@gnu.org > https://lists.gnu.org/mailman/listinfo/guile-user > > > ------------------------------ > > End of guile-user Digest, Vol 187, Issue 14 > *******************************************