From vbarr@cme.nist.gov Tue Jun 26 23:12:59 2001
Received: from dribble.cme.nist.gov (dribble.cme.nist.gov [129.6.32.31])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f5QLCwc26931
	for <prolog@swi.psy.uva.nl>; Tue, 26 Jun 2001 23:12:58 +0200 (MET DST)
Received: from ultraman.msid.cme.nist.gov (ultraman.msid.cme.nist.gov [129.6.77.98])
	by dribble.cme.nist.gov (8.9.3/8.9.3) with SMTP id RAA29007
	for <prolog@swi.psy.uva.nl>; Tue, 26 Jun 2001 17:12:56 -0400 (EDT)
Message-Id: <200106262112.RAA29007@dribble.cme.nist.gov>
Date: Tue, 26 Jun 2001 17:12:56 -0400 (EDT)
From: Vincent Manuel Barrilliot <vbarr@cme.nist.gov>
Reply-To: Vincent Manuel Barrilliot <vbarr@cme.nist.gov>
Subject: Re: [SWIPL] sockets: interrupting a server
To: prolog@swi.psy.uva.nl
MIME-Version: 1.0
Content-Type: TEXT/plain; charset=us-ascii
Content-MD5: bKa7oRrXv539k7DSB8jkfw==
X-Mailer: dtmail 1.2.1 CDE Version 1.2.1 SunOS 5.6 sun4u sparc 

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 <jan@swi.psy.uva.nl>
> Subject: Re: [SWIPL] sockets: interrupting a server
> To: Paul Singleton <p.singleton@keele.ac.uk>, SWI Prolog 
<prolog@swi.psy.uva.nl>
> Phone: +31 - 20 - 525 6121
> Resent-Message-ID: <4pfAeD.A.jCG.iAPO7@swi>
> Resent-From: prolog@swi.psy.uva.nl
> X-Mailing-List: <prolog@swi.psy.uva.nl> archive/latest/1454
> X-Loop: prolog@swi.psy.uva.nl
> Resent-Sender: prolog-request@swi.psy.uva.nl
> 
> 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 prolog-request@swi.psy.uva.nl 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/

