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 »

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 »

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 »

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 »

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 »

> 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: Bing [Bot] and 1 guest