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

Socket.Ttl プロパティ

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

Socket によって送信されインターネット プロトコル (IP) パケット有効期間 (TTL) の値を指定する値を取得または設定します

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

例外例外
例外種類条件

NotSupportedException

このプロパティは、InterNetwork ファミリまたは InterNetworkV6 ファミリソケットに対してだけ設定できます

SocketException

ソケットへのアクセス試みているときにエラー発生しました

ObjectDisposedException

Socket閉じられています。

解説解説
使用例使用例

Ttl プロパティ使用方法を示すコード例次に示します

static void ConfigureTcpSocket(Socket tcpSocket)
{
    // Don't allow another socket to bind to this port.
    tcpSocket.ExclusiveAddressUse = true;

    // The socket will linger for 10 seconds after 
                // Socket.Close is called.
    tcpSocket.LingerState = new LingerOption (true,
 10);

    // Disable the Nagle Algorithm for this tcp socket.
    tcpSocket.NoDelay = true;

    // Set the receive buffer size to 8k
    tcpSocket.ReceiveBufferSize = 8192;

    // Set the timeout for synchronous receive methods to 
    // 1 second (1000 milliseconds.)
    tcpSocket.ReceiveTimeout = 1000;

    // Set the send buffer size to 8k.
    tcpSocket.SendBufferSize = 8192;

    // Set the timeout for synchronous send methods
    // to 1 second (1000 milliseconds.)            
    tcpSocket.SendTimeout = 1000;

    // Set the Time To Live (TTL) to 42 router hops.
    tcpSocket.Ttl = 42;

    Console.WriteLine("Tcp Socket configured:");

    Console.WriteLine("  ExclusiveAddressUse {0}", 
                tcpSocket.ExclusiveAddressUse);

    Console.WriteLine("  LingerState {0}, {1}", 
                 tcpSocket.LingerState.Enabled, 
                     tcpSocket.LingerState.LingerTime);

    Console.WriteLine("  NoDelay {0}", 
                                        tcpSocket.NoDelay);

    Console.WriteLine("  ReceiveBufferSize {0}", 
                tcpSocket.ReceiveBufferSize);

    Console.WriteLine("  ReceiveTimeout {0}", 
                tcpSocket.ReceiveTimeout);

    Console.WriteLine("  SendBufferSize {0}", 
                tcpSocket.SendBufferSize);

    Console.WriteLine("  SendTimeout {0}", 
                                        tcpSocket.SendTimeout);

    Console.WriteLine("  Ttl {0}", 
                                        tcpSocket.Ttl);

                Console.WriteLine("  IsBound {0}", 
                                        tcpSocket.IsBound);

    Console.WriteLine("");
}
static void ConfigureTcpSocket(Socket^ tcpSocket)
{
     
    // Don't allow another socket to bind to this port.
    tcpSocket->ExclusiveAddressUse = true;
     
    // The socket will linger for 10 seconds after
    // Socket.Close is called.
    tcpSocket->LingerState = gcnew LingerOption(true, 10);
     
    // Disable the Nagle Algorithm for this tcp socket.
    tcpSocket->NoDelay = true;
     
    // Set the receive buffer size to 8k
    tcpSocket->ReceiveBufferSize = 8192;
     
    // Set the timeout for synchronous receive methods to
    // 1 second (1000 milliseconds.)
    tcpSocket->ReceiveTimeout = 1000;
     
    // Set the send buffer size to 8k.
    tcpSocket->SendBufferSize = 8192;
     
    // Set the timeout for synchronous send methods
    // to 1 second (1000 milliseconds.)
    tcpSocket->SendTimeout = 1000;
     
    // Set the Time To Live (TTL) to 42 router hops.
    tcpSocket->Ttl = 42;
    Console::WriteLine("Tcp Socket configured:");
    Console::WriteLine("  ExclusiveAddressUse {0}", 
        tcpSocket->ExclusiveAddressUse);
    Console::WriteLine("  LingerState {0}, {1}", 
        tcpSocket->LingerState->Enabled,
        tcpSocket->LingerState->LingerTime);
    Console::WriteLine("  NoDelay {0}",
        tcpSocket->NoDelay);
    Console::WriteLine("  ReceiveBufferSize {0}", 
        tcpSocket->ReceiveBufferSize);
    Console::WriteLine("  ReceiveTimeout {0}",
        tcpSocket->ReceiveTimeout);
    Console::WriteLine("  SendBufferSize {0}",
        tcpSocket->SendBufferSize);
    Console::WriteLine("  SendTimeout {0}",
        tcpSocket->SendTimeout);
    Console::WriteLine("  Ttl {0}",
        tcpSocket->Ttl);
    Console::WriteLine("  IsBound {0}",
        tcpSocket->IsBound);
    Console::WriteLine("");
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2024 GRAS Group, Inc.RSS