Subject: Re: [SWIPL] sockets: interrupting a server

From: Vincent Manuel Barrilliot <[email-masked]>
Date: Tue, 26 Jun 2001 17:12:56 -0400 (EDT)

Hello Paul,

I had kind of the same thing (on Solaris though) as you, except that I was not 
listening to a connection after the first one being closed.
What about writing a dumb program that connects to your Prolog server, and sends 
it a dummy message like "killYourself".

Your server can detect that and close the streams properly before exiting.
It's just a workaround though, you would have to run this little program to kill 
your server

Vincent

> Resent-Date: Tue, 26 Jun 2001 22:52:16 +0200 (MET DST)
> Date: Tue, 26 Jun 2001 22:27:09 +0200
> From: Jan Wielemaker <[email-masked]>
> Subject: Re: [SWIPL] sockets: interrupting a server
> To: Paul Singleton <[email-masked]>, SWI Prolog 
<[email-masked]>
> Phone: +31 - 20 - 525 6121
> Resent-Message-ID: <4pfAeD.A.jCG.iAPO7@swi>
> Resent-From: [email-masked]
> X-Mailing-List: <[email-masked]> archive/latest/1454
> X-Loop: [email-masked]
> Resent-Sender: [email-masked]
> 
> Paul,
> 
> > Summary: how can I make my library(socket) application interruptible?
> > 
> > I'm using library(socket) (on Windows NT4) to implement a simple Prolog
> > server: it runs in blocking mode, waits for a connection request, then
> > elaborates (determinate) queries until the connection is closed by the
> > client, whereupon it listens again ad infinitem.
> > 
> > Unfortunately it's very hard to kill!
> > 
> >   Waiting for Prolog.  Close again to force termination ..
> > 
> >   Main task is not responding.  Click "OK" to terminate it
> > 
> > Eventually it goes, but there's still a 'plwin.exe' process lurking,
> > which continues to hog the port.  I have to "End Process" from Task
> > Manager.  I haven't tried it, but I guess a Windows shutdown would hang.
> > 
> > Is this a problem with Windows and blocking mode?
> 
> Certainly.  In the Unix version you just do Control-C and abort or
> exit, but Windows doesn't know about signals (= software interrupts).
> 
> > I've had a peek at socket.c, and am willing to hack it (but I only have
> > documentation, and test capability, for Win32).
> 
> If you find something that works I'll be glad to integrate it.
> 
> > NB is the IO-stream stuff a model for implementing QP's with_output_to_chars
> > and vice versa?  It looks straightforward...
> 
> In good old SWI-Prolog you can use '$write_on_string'/2.  See for example
> sformat.  Version 4.0.7 contains `memory_file', which allows for creating
> an abstract object, opening it as a stream for reading and writing and
> get the content as an atom or list of character codes.  Check the clib
> package documentation.
> 
> 	Cheers --- Jan
> 
> 
> ----------------
> * To UNSUBSCRIBE, please use the HTML form at
> 
>     http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist
> 
> or send mail to [email-masked] using the Subject: "unsubscribe"
> (without the quotes) and *no* message body.
> 
> ** An ARCHIVE of this list is maintained at
> 
>     http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/