comparison OrthancServer/DicomProtocol/DicomServer.cpp @ 2069:fabf7820d1f1

New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 13 Jul 2016 16:52:39 +0200
parents 879f3be759ef
children 5a8840920121
comparison
equal deleted inserted replaced
2068:879f3be759ef 2069:fabf7820d1f1
119 uint16_t DicomServer::GetPortNumber() const 119 uint16_t DicomServer::GetPortNumber() const
120 { 120 {
121 return port_; 121 return port_;
122 } 122 }
123 123
124 void DicomServer::SetAssociationTimeout(uint32_t timeout) 124 void DicomServer::SetAssociationTimeout(uint32_t seconds)
125 { 125 {
126 Stop(); 126 LOG(INFO) << "Setting timeout for DICOM connections if Orthanc acts as SCP (server): "
127 associationTimeout_ = timeout; 127 << seconds << " seconds (0 = no timeout)";
128
129 Stop();
130 associationTimeout_ = seconds;
128 } 131 }
129 132
130 uint32_t DicomServer::GetAssociationTimeout() const 133 uint32_t DicomServer::GetAssociationTimeout() const
131 { 134 {
132 return associationTimeout_; 135 return associationTimeout_;
294 297
295 void DicomServer::Start() 298 void DicomServer::Start()
296 { 299 {
297 Stop(); 300 Stop();
298 301
299 uint32_t timeout = associationTimeout_;
300 if (timeout == 0)
301 {
302 timeout = 30; // Some safe value (30 seconds) if association timeout is disabled
303 }
304
305 /* initialize network, i.e. create an instance of T_ASC_Network*. */ 302 /* initialize network, i.e. create an instance of T_ASC_Network*. */
306 OFCondition cond = ASC_initializeNetwork 303 OFCondition cond = ASC_initializeNetwork
307 (NET_ACCEPTOR, OFstatic_cast(int, port_), /*opt_acse_timeout*/ timeout, &pimpl_->network_); 304 (NET_ACCEPTOR, OFstatic_cast(int, port_), /*opt_acse_timeout*/ 30, &pimpl_->network_);
308 if (cond.bad()) 305 if (cond.bad())
309 { 306 {
310 LOG(ERROR) << "cannot create network: " << cond.text(); 307 LOG(ERROR) << "cannot create network: " << cond.text();
311 throw OrthancException(ErrorCode_DicomPortInUse); 308 throw OrthancException(ErrorCode_DicomPortInUse);
312 } 309 }