NetworkStream.WriteTimeout プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > NetworkStream.WriteTimeout プロパティの意味・解説 

NetworkStream.WriteTimeout プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

書き込み操作データ待機する時間取得または設定します

名前空間: System.Net.Sockets
アセンブリ: System (system.dll 内)
構文構文

Public Overrides Property
 WriteTimeout As Integer
Dim instance As NetworkStream
Dim value As Integer

value = instance.WriteTimeout

instance.WriteTimeout = value
public override int WriteTimeout { get;
 set; }
/** @property */
public int get_WriteTimeout ()

/** @property */
public void set_WriteTimeout (int
 value)

プロパティ
書き込み操作失敗するまでの経過時間 (ミリ秒単位) を指定する Int32。既定値Infinite で、書き込み操作タイムアウトしないことを示します

例外例外
例外種類条件

ArgumentOutOfRangeException

指定した値が 0 以下のため Infinite ではありません。

解説解説
使用例使用例

ネットワーク ストリーム書き込みタイムアウト10 ミリ秒設定するコード例次に示します

using System;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace Examples.System.Net
{
    public class TCPListenerExample
    {
        public static void
 Main()
        {
            // Create the server side connection and 
            // start listening for clients.
            TcpListener tcpListener = new TcpListener(IPAddress.Any
,11000);
            tcpListener.Start();
            Console.WriteLine("Waiting for a connection....");

            // Accept the pending client connection.
            TcpClient tcpClient = tcpListener.AcceptTcpClient();
            Console.WriteLine("Connection accepted.");
            // Get the stream to write the message 
            // that will be sent to the client.
            NetworkStream networkStream = tcpClient.GetStream();
            string responseString = "Hello.";
            // Set the write timeout to 10 millseconds.
            networkStream.WriteTimeout = 10;
            // Convert the message to a byte array and sent it to the
 client.
            Byte[] sendBytes = Encoding.UTF8.GetBytes(responseString);
            networkStream.Write(sendBytes, 0, sendBytes.Length);
            Console.WriteLine("Message Sent.");
            // Close the connection to the client.
            tcpClient.Close();
            // Stop listening for incoming connections
            // and close the server.
            tcpListener.Stop();
        }
    }
}
#using <System.dll>
using namespace System;
using namespace System::Text;
using namespace System::Net;
using namespace System::Net::Sockets;

int main()
{
    // Create the server side connection and
    // start listening for clients.
    TcpListener^ tcpListener = gcnew TcpListener(IPAddress::Any, 11000);
    tcpListener->Start();
    Console::WriteLine("Waiting for a connection....");

    // Accept the pending client connection.
    TcpClient^ tcpClient = tcpListener->AcceptTcpClient();
    Console::WriteLine("Connection accepted.");
    // Get the stream to write the message
    // that will be sent to the client.
    NetworkStream^ networkStream = tcpClient->GetStream();
    String^ responseString = "Hello.";
    // Set the write timeout to 10 millseconds.
    networkStream->WriteTimeout = 10;
    // Convert the message to a byte array and sent it to the client.
    array<Byte>^ sendBytes = Encoding::UTF8->GetBytes(responseString);
    networkStream->Write(sendBytes, 0, sendBytes->Length);
    Console::WriteLine("Message Sent.");
    // Close the connection to the client.
    tcpClient->Close();
    // Stop listening for incoming connections
    // and close the server.
    tcpListener->Stop();
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NetworkStream クラス
NetworkStream メンバ
System.Net.Sockets 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

NetworkStream.WriteTimeout プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



NetworkStream.WriteTimeout プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS