fo-DICOM:如何在DicomClient中指定本地传出端口?

问题描述

TcpClient可以按照here的方式分配本地传出端口。

fo-DICOM DicomClient是否可以具有相同的功能

这是必需的,因为服务器仅在侦听来自特定客户端端口的连接。

解决方法

此答案适用于fo-DICOM的旧版本(4.0.1.0或附近)。对于最新版本,不建议使用此答案中提到的类和方法。


使用DicomClient.Send方法的重载,INetworkStream可用于在使用fo-DICOM作为SCU的同时提供本地输出端口。

作为示例,有四种方法可用于CSTORE作为SCU。前两个是:

public void Send(string host,int port,bool useTls,string callingAe,string calledAe,int millisecondsTimeout = 5000);
public Task SendAsync(string host,int millisecondsTimeout = 5000);

hostport是远程主机和远程端口。没有一个接受IPEndPoint作为参数。

现在,看看其他两种方法:

public void Send(INetworkStream stream,int millisecondsTimeout = 5000);
public Task SendAsync(INetworkStream stream,int millisecondsTimeout = 5000);

接受INetworkStream的人,如下所示:

public interface INetworkStream : IDisposable
{
    string LocalHost { get; }
    int LocalPort { get; }
    string RemoteHost { get; }
    int RemotePort { get; }
    Stream AsStream();
}

这允许向您提供LocalPort。您需要为该接口编写实现。不确定DesktopNetworkStreamINetworkStream的实现)是否可以直接使用。

,

您提出了issue on github。以下是那里的反馈:

当前不支持此功能。您可以通过实现自己的NetworkManager并从现有的DesktopNetworkManagerDesktopNetworkStream中汲取灵感来解决此限制。在DesktopNetworkStream中,创建了TcpClient。那是您需要进行自定义更改的地方。

看那里的reply to my comment,看来问题已经解决,并且该功能现在可用。