DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomServer Class / Accept Method
The underlying socket
A stream based on that socket
Example

In This Topic
    Accept Method
    In This Topic
    Means to allow DICOM negotiation on an existing socket
    Syntax
    'Declaration
     
    
    Public Sub Accept( _
       ByVal Socket As System.Net.Sockets.Socket, _
       ByVal Stream As System.IO.Stream _
    ) 
    public void Accept( 
       System.Net.Sockets.Socket Socket,
       System.IO.Stream Stream
    )

    Parameters

    Socket
    The underlying socket
    Stream
    A stream based on that socket
    Remarks

    Normally this is all handled internally by DicomObjects, but this method is provided for developers who may wish to use their own listening and authorisation mechanisms

    Note that only one association is allowed per TCP connection, so this does require a "new" TCP connection, though TLS negotiation etc. may of course have been performed.

    Example
    int port = 104;
    TcpListener listener = new TcpListener(System.Net.IPAddress.Any, port);
    listener.Start();
                
    while (true)
    {
        // Step 1: Accept a new TCP connection
        TcpClient client = listener.AcceptTcpClient();
        Console.WriteLine("New connection accepted.");
                
        // Step 2: Get the underlying socket and network stream
        Socket socket = client.Client;
        NetworkStream stream = client.GetStream();
                
        // Step 3: Pass the connection to DICOM for association negotiation
        Server.Accept(socket, stream);
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also