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

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

Socket.BeginDisconnect メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

リモート エンドポイントからの接続解除非同期要求開始します

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

Public Function BeginDisconnect ( _
    reuseSocket As Boolean, _
    callback As AsyncCallback, _
    state As Object _
) As IAsyncResult
Dim instance As Socket
Dim reuseSocket As Boolean
Dim callback As AsyncCallback
Dim state As Object
Dim returnValue As IAsyncResult

returnValue = instance.BeginDisconnect(reuseSocket, callback, state)
public IAsyncResult BeginDisconnect (
    bool reuseSocket,
    AsyncCallback callback,
    Object state
)
public:
IAsyncResult^ BeginDisconnect (
    bool reuseSocket, 
    AsyncCallback^ callback, 
    Object^ state
)
public IAsyncResult BeginDisconnect (
    boolean reuseSocket, 
    AsyncCallback callback, 
    Object state
)
public function BeginDisconnect (
    reuseSocket : boolean, 
    callback : AsyncCallback, 
    state : Object
) : IAsyncResult

パラメータ

reuseSocket

接続終了後、このソケット再利用できる場合trueそれ以外場合false

callback

AsyncCallback デリゲート

state

この要求ステータス情報格納するオブジェクト

戻り値
非同期操作参照する IAsyncResult オブジェクト

例外例外
解説解説
使用例使用例

非同期通信ソケット作成しリモート ホストデータ送信するコード例次に示しますデータ送信されると、Shutdown呼び出され送受信動作停止します次にBeginDisconnect呼び出され接続解除要求開始します要求完了すると、Connected プロパティ問い合わせ受けてソケット接続解除されたかどうかがテストされます。

    // Establish the remote endpoint for the socket.
    // For this example use local computer.
    IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
    IPAddress ipAddress = ipHostInfo.AddressList[0];
    IPEndPoint remoteEP = new IPEndPoint(ipAddress, 11000);

    // Create a TCP/IP socket.
    Socket client = new Socket(AddressFamily.InterNetwork,
        SocketType.Stream, ProtocolType.Tcp);

    // Connect to the remote endpoint.
    client.BeginConnect(remoteEP, 
        new AsyncCallback(ConnectCallback), client);
        
    // Wait for connect.
    connectDone.WaitOne();

    // Send some data to the remote device.
    string data = "This is a string of
 data <EOF>";
    byte[] buffer = Encoding.ASCII.GetBytes(data);
    client.BeginSend(buffer, 0, buffer.Length, 0, new AsyncCallback(ClientSendCallback),
 client);
    // Wait for send done.
    sendDone.WaitOne();

    // Release the socket.
    client.Shutdown(SocketShutdown.Both);
    client.BeginDisconnect(true, new AsyncCallback(DisconnectCallback),
 client);

    // Wait for the disconnect to complete.
    disconnectDone.WaitOne();
    if (client.Connected)
        Console.WriteLine("We're still connected");
    else
        Console.WriteLine("We're disconnected");
}


private static void DisconnectCallback(IAsyncResult
 ar)
{ 
    // Complete the disconnect request.
    Socket client = (Socket) ar.AsyncState;
    client.EndDisconnect(ar);

    // Signal that the disconnect is complete.
    disconnectDone.Set();
}
     
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


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

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS