[racket] tcp exceptions and connection reestablishment...

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Mon Jul 2 12:39:04 EDT 2012

I began by saying "This is quick off-the-cuff suggestion to consider, 
not the only way to do this (nor any kind of canonical recipe for doing 
this sort of thing, nor necessarily the best way)" for three reasons: 
(1) I think the right solution varies with the subtleties of one's 
application; (2) getting the networking code exactly right for a 
particular application takes a lot more head-scratching than banging out 
an email does; (3) if I had the perfect reusable code pattern already, I 
think it would be in a PLaneT package or a book chapter. :)

You mention "set!".  I think my eventual solutions to this kind of 
problem would usually look similar in style to that example I gave, but 
if I decided that "set!" would be helpful, I wouldn't be afraid to use 
it.  I'd probably have to spend hours working through details before I 
got to that point.  You also mention uniform handling; as you are 
refining your app's networking code, if you find you really don't want a 
particular procedure to return an exception, you can always wrap the 
call site tightly with a "with-handlers" that makes it return an error 
value instead,

Perhaps someone else has different suggestions.

Neil V.

Posted on the users mailing list.