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.