DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomServer Class / Unlisten Method / Unlisten(Int32,AddressFamily) Method

The port number which is to be closed for incoming connection.

Specifies whether the listener to be closed is using IPv4 or IPv6

Example

In This Topic
    Unlisten(Int32,AddressFamily) Method
    In This Topic
    Close a "Listening" TCP port, specified by the port number, for incoming DICOM Connections
    Syntax
    'Declaration
     
    
    Public Overloads Sub Unlisten( _
       ByVal Port As System.Integer, _
       Optional ByVal IpAddressFamily As System.Net.Sockets.AddressFamily _
    ) 
    public void Unlisten( 
       System.int Port,
       System.Net.Sockets.AddressFamily IpAddressFamily
    )

    Parameters

    Port

    The port number which is to be closed for incoming connection.

    IpAddressFamily

    Specifies whether the listener to be closed is using IPv4 or IPv6

    Remarks

    Closing a “listening” socket has no effect on currently active associations that connected via that socket.

    Example
    DicomServer server = new DicomServer();
                
    // Handle incoming DICOM association requests
    server.AssociationRequest += (sender, e) =>
    {
        Console.WriteLine($"Incoming DICOM association request from {e.Association.CallingAET}");
    };
                
    int port = 104;
    server.Listen(port, AddressFamily.InterNetwork, MinimalWindowsServer.GetDecryptedStream);
    server.Listen(port, AddressFamily.InterNetworkV6, MinimalWindowsServer.GetDecryptedStream); // IPv6
                
    server.Unlisten(port);
    server.Unlisten(port, AddressFamily.InterNetwork); // equivalent to server.Unlisten(port)
    // Please pass AddressFamily.InterNetworkV6 to Unlisten if you are unlistening a IPv6 listener
    server.Unlisten(port, AddressFamily.InterNetworkV6);
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also