This documentation is archived and is not being maintained.

SslStream.WriteTimeout Property

Gets or sets the amount of time a write operation blocks waiting for data.

Namespace:  System.Net.Security
Assembly:  System (in System.dll)

public override function get WriteTimeout () : int 
public override function set WriteTimeout (value : int)

Property Value

Type: System.Int32
A Int32 that specifies the amount of time that elapses before a synchronous write operation fails.

This property returns the value returned by invoking WriteTimeout on the underlying stream. For set operations, the specified value sets the WriteTimeout value on the underlying stream.

If the underlying stream is a NetworkStream, WriteTimeout is in milliseconds and is set to Infinite by default so that write operations do not timeout.

The following code example demonstrates setting the value of this property.

No code example is currently available or this language may not be supported.
static void ProcessClient (TcpClient* client)
    // A client has connected. Create the 
    // SslStream using the client's network stream.
    SslStream* sslStream = new SslStream(
        client->GetStream(), false);
    // Authenticate the server but don't require the client to authenticate.
            false, SslProtocolType::Tls, true);
        // Display the properties and settings for the authenticated stream.

        // Set timeouts for the read and write to 5 seconds.
        sslStream->ReadTimeout = 5000;
        sslStream->WriteTimeout = 5000;
        // Read a message from the client.   
        Console::WriteLine(S"Waiting for client message...");
        String* messageData = ReadMessage(sslStream);
        Console::WriteLine(S"Received: {0}", messageData);

        // Write a message to the client.
        Byte message[] = Encoding::UTF8->GetBytes(S"Hello from the server.<EOF>");
        Console::WriteLine(S"Sending hello message.");
    catch (AuthenticationException* e)
        Console::WriteLine(S"Exception: {0}", e->Message);
        if (e->InnerException != 0)
            Console::WriteLine(S"Inner exception: {0}", e->InnerException->Message);
        Console::WriteLine (S"Authentication failed - closing the connection.");
        // The client stream will be closed with the sslStream
        // because we specified this behavior when creating
        // the sslStream.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0