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

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

TcpListener.AcceptSocket メソッド

保留中の接続要求受け入れます

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

Dim instance As TcpListener
Dim returnValue As Socket

returnValue = instance.AcceptSocket
public Socket AcceptSocket ()
public:
Socket^ AcceptSocket ()
public Socket AcceptSocket ()

戻り値
データの送受信使用する Socket

例外例外
例外種類条件

InvalidOperationException

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

解説解説
使用例使用例

AcceptSocket メソッド使用してSocket返すコード例次に示します。この Socket は、新しく接続したクライアントとの通信使用します

' Accepts the pending client connection and returns a socket for communciation.
Dim socket As Socket = tcpListener.AcceptSocket()
Console.WriteLine("Connection accepted.")

Dim responseString As String
 = "You have successfully connected to me"

'Forms and sends a response string to the connected client.
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString)
Dim i As Integer = socket.Send(sendBytes)
Console.WriteLine(("Message Sent /> : " + responseString))
           
// Accepts the pending client connection and returns a socket for communciation.
 Socket socket = tcpListener.AcceptSocket();
   Console.WriteLine("Connection accepted.");

 string responseString = "You have successfully connected
 to me";

 //Forms and sends a response string to the connected client.
 Byte[] sendBytes = Encoding.ASCII.GetBytes(responseString);
 int i = socket.Send(sendBytes);
 Console.WriteLine("Message Sent /> : " + responseString);
// Accepts the pending client connection and returns a socket for communciation.
Socket^ socket = tcpListener->AcceptSocket();
Console::WriteLine( "Connection accepted." );

String^ responseString = "You have successfully connected to me";

//Forms and sends a response string to the connected client.
array<Byte>^sendBytes = Encoding::ASCII->GetBytes( responseString );
int i = socket->Send( sendBytes );
Console::WriteLine( "Message Sent /> : {0}", responseString );
// Accepts the pending client connection and returns a 
// socket for communciation.
Socket socket = tcpListener.AcceptSocket();
Console.WriteLine("Connection accepted.");
String responseString = 
    "You have successfully connected to me";

// Forms and sends a response string to the connected 
// client.
ubyte sendBytes[] = Encoding.get_ASCII().GetBytes(
                        responseString);
int i = socket.Send(sendBytes);
Console.WriteLine(("Message Sent /> : "
    + responseString));
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TcpListener クラス
TcpListener メンバ
System.Net.Sockets 名前空間
AcceptTcpClient
Socket クラス
Pending


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

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS