Re: TCP Socket keepalive
Haitao Zhang <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CAFUyvhpnEm-Kcas+VQ98303Z6Ek4yWMAx7S6Msbw5gdmPDocnw@mail.gmail.com> |
Hi Jan, Thanks for the response. I will take a look at tcp_setopt/setsockopt. On a related note, after the send error (as the socket closed unexpectedly) if I call close/1 on the stream, I get the same error. Now that is a little confusing. Shouldn't close/1 just silently ignore the error? tcp_close_socket on the other hand seems to gracefully handle the situation. When I close down a channel, should I A) just call tcp_close_socket on the socket, and don't call close on the stream? or B) do both, but wrap the close on the stream to trap the error condition? It seems weird that one needs to wrap the close/1 since it should be in the cleanup clause of an exception handler. Haitao On Tue, Dec 10, 2013 at 12:57 AM, Jan Wielemaker <[email protected]> wrote: > On 12/10/2013 08:26 AM, Haitao Zhang wrote: > >> I have a problem with the TCP socket, where SWI Prolog is client, >> disappearing after some time (presumably some inactivity timer expired). I >> have set my server side to keepalive, but that does not seem to help. >> >> The message I get from trying to use the socket again after a long idle >> time: >> ERROR: format/3: I/O error in write on stream <stream>(000000000834B260) >> (Socket operation on non-socket) >> >> Any idea on how keep the socket alive? >> > > There is tcp_setopt/2, which binds to setsockopt(). It doesn't support > the SO_KEEPALIVE option yet. Should be easy enough to add. If you use > a source version, see packages/clib. Try it and submit a patch with > additional options you see fit. > > Hope this helps > > --- Jan > > > >> Thanks, >> Haitao >> -------------- next part -------------- >> HTML attachment scrubbed and removed >> _______________________________________________ >> SWI-Prolog mailing list >> [email protected] >> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog >> >> > -------------- next part -------------- HTML attachment scrubbed and removed