UdpClientとは何? わかりやすく解説 Weblio辞書 (original) (raw)
UdpClient クラス
ユーザー データグラム プロトコル (UDP) ネットワーク サービスを提供します。
名前空間: System.Net.Sockets
アセンブリ: System (system.dll 内)
構文
ポート 11000 上のホスト名 www.contoso.com を使用して UdpClient 接続を確立する例を次に示します。2 つの別個のリモート ホスト コンピュータに小さな文字列メッセージが送信されます。Receive メソッドはメッセージを受信するまで実行をブロックします。**Receive** に渡された IPEndPoint を使用して、応答するホストの ID が明らかになります。
// With this constructor the local port number is arbitrarily assigned. UdpClient^ udpClient = gcnew UdpClient; try { udpClient->Connect( "host.contoso.com", 11000 );
// Send message to the host to which you have connected. array<Byte>^sendBytes = Encoding::ASCII->GetBytes( "Is anybody there?" ); udpClient->Send( sendBytes, sendBytes->Length );
// Send message to a different host using optional hostname and port parameters. UdpClient^ udpClientB = gcnew UdpClient; udpClientB->Send( sendBytes, sendBytes->Length, "AlternateHostMachineName", 11000 );
//IPEndPoint object will allow us to read datagrams sent from any source. IPEndPoint^ RemoteIpEndPoint = gcnew IPEndPoint( IPAddress::Any,0 );
// Block until a message returns on this socket from a remote host. array<Byte>^receiveBytes = udpClient->Receive( RemoteIpEndPoint ); String^ returnData = Encoding::ASCII->GetString( receiveBytes );
// Use the IPEndPoint object to determine which of these two hosts responded. Console::WriteLine( String::Concat( "This is the message you received ", returnData->ToString() ) ); Console::WriteLine( String::Concat( "This message was sent from ", RemoteIpEndPoint->Address->ToString(), " on their port number ", RemoteIpEndPoint->Port.ToString() ) ); udpClient->Close(); udpClientB->Close(); } catch ( Exception^ e ) { Console::WriteLine( e->ToString() ); }
- SocketPermission 送信接続を確立するか、受信要求を受け入れるための **SocketPermission**。
System.Object
System.Net.Sockets.UdpClient
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
UdpClient コンストラクタ ()
UdpClient クラスの新しいインスタンスを初期化します。
名前空間: System.Net.Sockets
アセンブリ: System (system.dll 内)
構文
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
UdpClient コンストラクタ (Int32, AddressFamily)
UdpClient クラスの新しいインスタンスを初期化し、指定したローカル ポート番号にバインドします。
名前空間: System.Net.Sockets
アセンブリ: System (system.dll 内)
構文
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
UdpClient コンストラクタ (Int32)
UdpClient クラスの新しいインスタンスを初期化し、指定したローカル ポート番号にバインドします。
名前空間: System.Net.Sockets
アセンブリ: System (system.dll 内)
構文
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
UdpClient コンストラクタ (String, Int32)
UdpClient クラスの新しいインスタンスを初期化し、既定のリモート ホストを確立します。
名前空間: System.Net.Sockets
アセンブリ: System (system.dll 内)
構文
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
UdpClient コンストラクタ (AddressFamily)
UdpClient クラスの新しいインスタンスを初期化します。
名前空間: System.Net.Sockets
アセンブリ: System (system.dll 内)
構文
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
UdpClient コンストラクタ (IPEndPoint)
UdpClient クラスの新しいインスタンスを初期化し、指定したローカル エンドポイントにバインドします。
名前空間: System.Net.Sockets
アセンブリ: System (system.dll 内)
構文
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。