简体   繁体   中英

fo-DICOM: How to specify the local outgoing port in DicomClient?

There is way for TcpClient to assign local outgoing port as described here .

Is it possible to have the same functionality for fo-DICOM DicomClient ?

This is necessary because the server is listening for a connection from a specific client port only.

This answer is applicable to older (4.0.1.0 or nearby) versions of fo-DICOM. With latest version, the classes and methods mentioned in this answer are deprecated.


Using overload of DicomClient.Send method, the INetworkStream can be used to provide local outgoing port while working as SCU using fo-DICOM.

As an example, there are four methods available for CSTORE as SCU. First two are:

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

The host and port are remote host and remote port. None of it accept IPEndPoint as parameter.

Now, look at other two methods:

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

Those accept INetworkStream which looks like below:

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

This allow providing LocalPort to you. You need to write implementation for that interface. Not sure if DesktopNetworkStream (implementation of INetworkStream ) can be used directly.

You have raised an issue on github . Following is the feedback from there:

This is currently not supported. You can work around this limitation by implementing your own NetworkManager , and taking heavy inspiration from the existing DesktopNetworkManager and DesktopNetworkStream . In DesktopNetworkStream , the TcpClient is created. That is the place where you would need to make your own custom changes.

Looking at the reply to my comment there, it appears that the issue is now fixed and the feature is now available.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM