Method: DICOM::DServer#initialize

Defined in:
lib/dicom/d_server.rb

#initialize(port = 104, options = {}) ⇒ DServer

Note:

To customize logging behaviour, refer to the Logging module documentation.

Creates a DServer instance.

Examples:

Create a server using default settings

s = DICOM::DServer.new

Create a server with a specific host name and a custom buildt file handler

require_relative 'my_file_handler'
server = DICOM::DServer.new(104, :host_ae => "RUBY_SERVER", :file_handler => DICOM::MyFileHandler)

Parameters:

  • port (Integer) (defaults to: 104)

    the network port to be used

  • options (Hash) (defaults to: {})

    the options to use for the DICOM server

Options Hash (options):

  • :file_handler (String)

    a customized FileHandler class to use instead of the default FileHandler

  • :host (String)

    the hostname that the TCPServer binds to (defaults to ‘0.0.0.0’)

  • :host_ae (String)

    the name of the server (application entity)

  • :max_package_size (String)

    the maximum allowed size of network packages (in bytes)

  • :timeout (String)

    the number of seconds the server will wait on an answer from a client before aborting the communication



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/dicom/d_server.rb', line 66

def initialize(port=104, options={})
  require 'socket'
  # Required parameters:
  @port = port
  # Optional parameters (and default values):
  @file_handler = options[:file_handler] || FileHandler
  @host = options[:host] || '0.0.0.0'
  @host_ae =  options[:host_ae]  || "RUBY_DICOM"
  @max_package_size = options[:max_package_size] || 32768 # 16384
  @timeout = options[:timeout] || 10 # seconds
  @min_length = 12 # minimum number of bytes to expect in an incoming transmission
  # Variables used for monitoring state of transmission:
  @connection = nil # TCP connection status
  @association = nil # DICOM Association status
  @request_approved = nil # Status of our DICOM request
  @release = nil # Status of received, valid release response
  set_default_accepted_syntaxes
end