When a PC has multiple IP Addresses, sometimes people would like to specify one of them to be used for connecting out to other DICOM AEs. This can be easily achieved in the .NET

version of DicomObjects. The following CSharp sample code shows how this could be done:

    DicomAssociation cn = new DicomAssociation();
    Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp;
    socket.Bind( new IPEndPoint(IPAddress.Parse(""), 0));
    socket.Connect(RemoteIPAddress, RemotePortNumber);
    NetworkStream netStream = new NetworkStream(socket);
    cn.Open(socket, netStream, "scu", "scp");

In the code above, IP Address “” is one of the multiple IP Addresses the machine has. RemoteIPAddress and RemotePortNumber are the IP Addresses and port number it is going to connect to.


The above code requires System.Net and System.Net.Sockets name spaces.