internal DicomServer(Socket socket, Dictionary <string, ListenerInfo> appList) { var remote = (IPEndPoint)socket.RemoteEndPoint; _host = remote.Address.ToString(); _socket = socket; _network = new NetworkStream(_socket); _closedEvent = null; _handler = null; _appList = appList; // Start background thread for incoming associations InitializeNetwork(_network, "DicomServer: " + _host, false); }
/// <summary> /// Method called when receiving an association request. /// </summary> /// <param name="association"></param> protected override void OnReceiveAssociateRequest(ServerAssociationParameters association) { ListenerInfo info; if (!_appList.TryGetValue(association.CalledAE, out info)) { Platform.Log(LogLevel.Error, "Rejecting association from {0}: Invalid Called AE Title ({1}).", association.CallingAE, association.CalledAE); SendAssociateReject(DicomRejectResult.Permanent, DicomRejectSource.ServiceProviderACSE, DicomRejectReason.CalledAENotRecognized); return; } // Populate the AssociationParameters properly association.ReadTimeout = info.Parameters.ReadTimeout; association.ReceiveBufferSize = info.Parameters.ReceiveBufferSize; association.WriteTimeout = info.Parameters.WriteTimeout; association.SendBufferSize = info.Parameters.SendBufferSize; association.RemoteEndPoint = _socket.RemoteEndPoint as IPEndPoint; association.LocalEndPoint = _socket.LocalEndPoint as IPEndPoint; // Setup Socketoptions based on the user's settings SetSocketOptions(association); // Select the presentation contexts bool anyValidContexts = NegotiateAssociation(association, info.Parameters); if (!anyValidContexts) { Platform.Log(LogLevel.Error, "Rejecting association from {0}: No valid presentation contexts.", association.CallingAE); SendAssociateReject(DicomRejectResult.Permanent, DicomRejectSource.ServiceProviderACSE, DicomRejectReason.NoReasonGiven); return; } _appList = null; try { _handler = info.StartDelegate(this, association); _handler.OnReceiveAssociateRequest(this, association); } catch (Exception e) { OnUserException(e, "Unexpected exception on OnReceiveAssociateRequest or StartDelegate"); } }
internal DicomServer(Socket socket, Dictionary<string,ListenerInfo> appList) { var remote = (IPEndPoint)socket.RemoteEndPoint; _host = remote.Address.ToString(); _socket = socket; _network = new NetworkStream(_socket); _closedEvent = null; _handler = null; _appList = appList; // Start background thread for incoming associations InitializeNetwork(_network, "DicomServer: " + _host, false); }