TcpListener.Pending メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > TcpListener.Pending メソッドの意味・解説 

TcpListener.Pending メソッド

保留中の接続要求があるかどうか確認します

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

例外例外
例外種類条件

InvalidOperationException

リスナが、Start への呼び出し開始されていません。

解説解説
使用例使用例

Pending メソッドチェックするコード例次に示します受け入れ待機している接続要求があると、AcceptTcpClient メソッド呼び出されます。

Try

     Dim ipAddress As IPAddress = Dns.Resolve("localhost").AddressList(0)
  Dim tcpListener As New
 TcpListener(ipAddress, portNumber)
  tcpListener.Start()
  
   ' Use the Pending method to poll the underlying socket instance for
 client connection requests.
   If Not tcpListener.Pending() Then
      
      Console.WriteLine("Sorry, no connection requests have arrived")
   
   Else
      
      'Accept the pending client connection and return a TcpClient object
 initialized for communication.
      Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
      ' Using the RemoteEndPoint property.
      Console.Write("I am listening for connections on ")
      Console.Writeline(IPAddress.Parse(CType(tcpListener.LocalEndpoint, IPEndPoint).Address.ToString()))
 
      Console.Write("on port number ")
      Console.Write(CType(tcpListener.LocalEndpoint, IPEndPoint).Port.ToString())
      
        
try{
        // Use the Pending method to poll the underlying socket instance
 for client connection requests.
            IPAddress ipAddress = Dns.Resolve("localhost").AddressList[0];
         TcpListener tcpListener =  new TcpListener(ipAddress,
 portNumber); 
         tcpListener.Start();
         
          if (!tcpListener.Pending()) {

          Console.WriteLine("Sorry, no connection requests have arrived");
          
       }
       else{

             //Accept the pending client connection and return a TcpClient
 object initialized for communication.
             TcpClient tcpClient = tcpListener.AcceptTcpClient();
             // Using the RemoteEndPoint property.
             Console.WriteLine("I am listening for connections
 on " + 
                                         IPAddress.Parse(((IPEndPoint)tcpListener.LocalEndpoint).Address.ToString())
 +
                                            "on port number " + ((IPEndPoint)tcpListener.LocalEndpoint).Port.ToString());

try
{
   // Use the Pending method to poll the underlying socket instance
 for client connection requests.
   TcpListener^ tcpListener = gcnew TcpListener( portNumber );
   tcpListener->Start();

   if ( !tcpListener->Pending() )
   {
      Console::WriteLine( "Sorry, no connection requests have arrived"
 );
   }
   else
   {
      //Accept the pending client connection and return a TcpClient
 object^ initialized for communication.
      TcpClient^ tcpClient = tcpListener->AcceptTcpClient();
      
      // Using the RemoteEndPoint property.
      Console::WriteLine( "I am listening for connections
 on {0} on port number {1}",
         IPAddress::Parse( ( (IPEndPoint^)(tcpListener->LocalEndpoint) )->Address->ToString()
 ),
         ( (IPEndPoint^)(tcpListener->LocalEndpoint) )->Port );
try {
    // Use the Pending method to poll the underlying socket instance
    // for client connection requests.
    IPAddress ipAddress = Dns.Resolve("localhost").get_AddressList()[0];
    TcpListener tcpListener = new TcpListener(ipAddress, portNumber);
    tcpListener.Start();

    if (!(tcpListener.Pending())) {
        Console.WriteLine("Sorry, no connection requests have arrived");
    }
    else {
        //Accept the pending client connection and return a TcpClient
        //object initialized for communication.
        TcpClient tcpClient = tcpListener.AcceptTcpClient();
        // Using the RemoteEndPoint property.
        Console.WriteLine("I am listening for connections
 on "
            + IPAddress.Parse(((IPEndPoint)
            (tcpListener.get_LocalEndpoint())).get_Address().ToString())
            + "on port number " + ((Int32)((IPEndPoint)
            (tcpListener.get_LocalEndpoint())).get_Port()).ToString());
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TcpListener クラス
TcpListener メンバ
System.Net.Sockets 名前空間
Start
AcceptSocket
AcceptTcpClient


このページでは「.NET Framework クラス ライブラリ リファレンス」からTcpListener.Pending メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からTcpListener.Pending メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からTcpListener.Pending メソッド を検索

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

辞書ショートカット

すべての辞書の索引

TcpListener.Pending メソッドのお隣キーワード
検索ランキング

   

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



TcpListener.Pending メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS