A very basic C-ECHO SCP sample code which would work with FO-DICOM v.5

62 views
Skip to first unread message

stacy....@gmail.com

unread,
Mar 19, 2024, 3:54:10 AM3/19/24
to Fellow Oak DICOM
Hello,
I need a very basic code snippet implementing C-ECHO SCP with FO-DICOM 5. All examples I was able to find including ChatGPT etc. do not work, since, as far as I understand, the signatures of the major routines changed from v4 to v5 and the latter is as good as not documented (at least, no comprehensible howto examples).
Thanks for any tips.
Stacy

Senthil Kumar

unread,
Oct 15, 2025, 6:45:03 AMOct 15
to Fellow Oak DICOM
Private Async Sub MaterialButton1_Click_1(sender As Object, e As EventArgs) Handles MaterialButton1.Click
Dim host As String = "192.168.0.104"
Dim port As Integer = 104
Dim useTls As Boolean = False
Dim callingAET As String = "SCU"
Dim calledAET As String = "SunNuclear_SCP"

Dim client As IDicomClient =
DicomClientFactory.Create(host, port, useTls, callingAET, calledAET)
Dim echoRequest As New DicomCEchoRequest()
echoRequest.OnResponseReceived = Sub(request As DicomCEchoRequest, response As DicomCEchoResponse)
 If response.Status = DicomStatus.Success Then
 Console.WriteLine("C-ECHO succeeded: " & response.Status.ToString())
 MessageBox.Show("Success")
 Else
 Console.WriteLine("C-ECHO failed with status: " & response.Status.ToString())
 End If

 End Sub

Try
Await client.AddRequestAsync(echoRequest)
Await client.SendAsync()
Catch ex As Exception
Console.WriteLine("C-ECHO failed: " & ex.Message)
MessageBox.Show("C-ECHO failed: " & ex.Message)
End Try
End Sub

This code worked for me. I was using FO-Dicom 5.2.4 . To get this Echo response working, it was quite difficult even with all the AI available.

Alieksandr Kuznietsov

unread,
Oct 15, 2025, 10:04:12 AMOct 15
to Fellow Oak DICOM
 I use this code. It works :)

public class EchoDicom
    {
        private static bool echoSuccess = false;

        public static async Task<bool> EchoAsync(DicomPacs? pacs)      
        {
            try
            {            
                if (!EchoPing(pacs.IpServer)) return false;

                var client = DicomClientFactory.Create(pacs.IpServer, int.Parse(pacs.DicomPort), false, pacs.LocalAet, pacs.AeTitle);
                client.NegotiateAsyncOps();
                var requestEcho = new DicomCEchoRequest();
                requestEcho.OnResponseReceived += EchoResponse;
                await client.AddRequestAsync(requestEcho).ConfigureAwait(true);
                await client.SendAsync().ConfigureAwait(true);

                if (echoSuccess) { return true; }
                else { return false; }
            }            
            catch (Exception ex)
            {
                return false;
            }
        }        

        private static void EchoResponse(DicomCEchoRequest request, DicomCEchoResponse response)
        {

            if (response.Status.ToString() == "Success")
            {
                echoSuccess = true;
                return;
            }
            else
            {
                echoSuccess = false;
            }
        }

        public static bool EchoPing(string ipAddress)      
        {
            try
            {
                Ping ping = new Ping();
                IPAddress address = IPAddress.Parse(ipAddress);              
                var pingResult = ping.Send(address, 1000);            

                if (pingResult.Status == IPStatus.Success)
                {
                    return true;
                }
                return false;
            }
            catch (Exception ex)
            {
                Program.Log.Error($"ОШИБКА пинга сервера: {ex.Message}.");                
                return false;
            }
        }
    }

Here https://telepacs.com.ua/?p=641 I provide the full program code.

среда, 15 октября 2025 г. в 13:45:03 UTC+3, senthilk...@gmail.com:
Reply all
Reply to author
Forward
0 new messages