Graceful shutdown of DcmScp

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
marcus
Posts: 9
Joined: Tue, 2004-11-09, 13:54

Graceful shutdown of DcmScp

#1 Post by marcus » Fri, 2012-11-16, 20:50

I am writing a C-STORE SCP using the DcmSCP class and I am unable to find a way to gracefully shutdown the SCP.

If I use the blocking connection mode, then the method DcmSCP::listen() never returns, so I have to forcefully terminate the thread.

Alternatively, if I use the non-blocking connection mode, then DcmSCP::listen() does return after a timeout is elapsed, but it does not seem possible to call it in a loop like this:

Code: Select all

while(continueRunning())
{
    scp->listen();
}
In this loop, the listen() method only works on the first iteration. On subsequent calls it just returns immediately without waiting for any further connections.

Is there a way to shutdown the SCP?

I am using the 20121102 snapshot on Windows and my GUI thread is separate from the thread that runs the SCP.

Thanks,
Marcus

omarelgazzar
Posts: 101
Joined: Wed, 2009-07-08, 16:06
Location: Oldenburg, Germany

Re: Graceful shutdown of DcmScp

#2 Post by omarelgazzar » Tue, 2012-11-20, 14:22

One way to stop listening is to overwrite the function stopAfterCurrentAssociation and to let the function return OFTrue. This will cause the DCMSCP to stop listening after the current association.

marcus
Posts: 9
Joined: Tue, 2004-11-09, 13:54

Re: Graceful shutdown of DcmScp

#3 Post by marcus » Tue, 2012-11-20, 18:05

Hi omarelgazzar,
Yes I have done that. But the listen() function still blocks while waiting for an association. If no more incoming connections are received then listen() never returns.

omarelgazzar
Posts: 101
Joined: Wed, 2009-07-08, 16:06
Location: Oldenburg, Germany

Re: Graceful shutdown of DcmScp

#4 Post by omarelgazzar » Wed, 2012-11-21, 10:24

Right. The function stopAfterCurrentAssociation() will cause the DcmSCP to stop listening after receiving the next association.

marcus
Posts: 9
Joined: Tue, 2004-11-09, 13:54

Re: Graceful shutdown of DcmScp

#5 Post by marcus » Wed, 2012-12-05, 13:36

> The function stopAfterCurrentAssociation() will cause the DcmSCP to stop listening after receiving the next association.

I am writing a DICOM client, so the STORE SCP will only receive images that are requested from a server using GET, and that means there are very unlikely to be any incoming associations at any other time. Also, in some cases the server might not respond, and then there won't be any incoming associations.

So it would be useful to have a way to interrupt DcmSCP::listen before it receives the next association.

Can I submit a feature request for this?

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest