MulticastOptionとは? わかりやすく解説

MulticastOption クラス

マルチキャスト グループへの参加および参加取り消し使用する IPAddress の値を格納します

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

Public Class MulticastOption
Dim instance As MulticastOption
public class MulticastOption
public ref class MulticastOption
public class MulticastOption
public class MulticastOption
解説解説

MulticastOption使用して参加する、または参加取り消すマルチキャスト グループIPAddress格納します。Socket.SetSocketOption メソッド次に示すパラメータと共に使用してマルチキャスト グループ参加します

パラメータ

socketOptionLevel

SocketOptionLevel.Udp

socketOptionName

AddMembership

Object

MulticastOption

DropMembership を使用してマルチキャスト グループへの参加取り消します

使用例使用例

既定IP インターフェイスIP マルチキャスト グループ参加させる例を次に示します。ここでは、IP マルチキャスト グループ アドレスが 224.0.0.0 ~ 239.255.255.255 の範囲であることを想定してます。

' This is the listener example that shows how to use the MulticastOption
 class. 
' In particular, it shows how to use the MulticastOption(IPAddress,
 IPAddress) 
' constructor, which you need to use if you have a host with more than
 one 
' network card.
' The first parameter specifies the multicast group address, and the
 second 
' specifies the local address of the network card you want to use for
 the data
' exchange.
' You must run this program in conjunction with the sender program as
 
' follows:
' Open a console window and run the listener from the command line.
 
' In another console window run the sender. In both cases you must specify
 
' the local IPAddress to use. To obtain this address run the ipconfig
 comand 
' from the command line. 


Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Imports Microsoft.VisualBasic


Namespace Mssc.TransportProtocols.Utilities

  Module M_TestMulticastOption

    Public Class TestMulticastOption

      Private Shared mcastAddress As
 IPAddress
      Private Shared mcastPort As
 Integer
      Private Shared mcastSocket As
 Socket
      Private Shared mcastOption As
 MulticastOption


      Private Shared Sub
 MulticastOptionProperties()
        Console.WriteLine(("Current multicast group is: "
 + mcastOption.Group.ToString()))
        Console.WriteLine(("Current multicast local address is:
 " + mcastOption.LocalAddress.ToString()))
      End Sub 'MulticastOptionProperties


      Private Shared Sub
 StartMulticast()

        Try
          mcastSocket = New Socket(AddressFamily.InterNetwork,
 SocketType.Dgram, ProtocolType.Udp)

          Console.Write("Enter the local IP address: ")

          Dim localIPAddr As IPAddress = IPAddress.Parse(Console.ReadLine())

          'IPAddress localIP = IPAddress.Any;
          Dim localEP As EndPoint = CType(New
 IPEndPoint(localIPAddr, mcastPort), EndPoint)

          mcastSocket.Bind(localEP)

          ' Define a MulticastOption object specifying the multicast
 group 
          ' address and the local IPAddress.
          ' The multicast group address is the same as the address used
 by the server.
          mcastOption = New MulticastOption(mcastAddress, localIPAddr)

          mcastSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership,
 mcastOption)

        Catch e As Exception
          Console.WriteLine(e.ToString())
        End Try
      End Sub 'StartMulticast


      Private Shared Sub
 ReceiveBroadcastMessages()
        Dim done As Boolean
 = False
        Dim bytes() As Byte
 = New [Byte](99) {}
        Dim groupEP As New
 IPEndPoint(mcastAddress, mcastPort)
        Dim remoteEP As EndPoint = CType(New
 IPEndPoint(IPAddress.Any, 0), EndPoint)


        Try
          While Not done
            Console.WriteLine("Waiting for multicast packets.......")
            Console.WriteLine("Enter ^C to terminate.")

            mcastSocket.ReceiveFrom(bytes, remoteEP)

            Console.WriteLine("Received broadcast from {0} :"
 + ControlChars.Lf + " {1}" + ControlChars.Lf, groupEP.ToString(),
 Encoding.ASCII.GetString(bytes, 0, bytes.Length))
          End While



          mcastSocket.Close()

        Catch e As Exception
          Console.WriteLine(e.ToString())
        End Try
      End Sub 'ReceiveBrodcastMessages


      Public Shared Sub
 Main(ByVal args() As String)
        ' Initialize the multicast address group and multicast port.
        ' Both address and port are selected from the allowed sets as
        ' defined in the related RFC documents. These are the same
        ' as the values used by the sender.
        mcastAddress = IPAddress.Parse("224.168.100.2")
        mcastPort = 11000

        ' Start a multicast group.
        StartMulticast()

        ' Display MulticastOption properties.
        MulticastOptionProperties()

        ' Receive broadcast messages.
        ReceiveBroadcastMessages()
      End Sub 'Main
    End Class 'TestMulticastOption

  End Module

End Namespace
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;


// This is the listener example that shows how to use the MulticastOption
 class. 
// In particular, it shows how to use the MulticastOption(IPAddress,
 IPAddress) 
// constructor, which you need to use if you have a host with more than
 one 
// network card.
// The first parameter specifies the multicast group address, and the
 second 
// specifies the local address of the network card you want to use for
 the data
// exchange.
// You must run this program in conjunction with the sender program
 as 
// follows:
// Open a console window and run the listener from the command line.
 
// In another console window run the sender. In both cases you must
 specify 
// the local IPAddress to use. To obtain this address run the ipconfig
 comand 
// from the command line. 
//  
namespace Mssc.TransportProtocols.Utilities
{

  public class TestMulticastOption 
  {

    private static IPAddress mcastAddress;
    private static int mcastPort;
    private static Socket mcastSocket;
    private static MulticastOption mcastOption;


    private static void
 MulticastOptionProperties()
    {
      Console.WriteLine("Current multicast group is: " + mcastOption.Group);
      Console.WriteLine("Current multicast local address is: " + mcastOption.LocalAddress);
    }


    private static void
 StartMulticast() 
    {
    
      try 
      {
        mcastSocket = new Socket(AddressFamily.InterNetwork,
                                 SocketType.Dgram, 
                                 ProtocolType.Udp);
        
        Console.Write("Enter the local IP address: ");

        IPAddress localIPAddr = IPAddress.Parse(Console.ReadLine());
      
        //IPAddress localIP = IPAddress.Any;
        EndPoint localEP = (EndPoint)new IPEndPoint(localIPAddr,
 mcastPort);

        mcastSocket.Bind(localEP);

 
        // Define a MulticastOption object specifying the multicast
 group 
        // address and the local IPAddress.
        // The multicast group address is the same as the address used
 by the server.
        mcastOption = new MulticastOption(mcastAddress, localIPAddr);

        mcastSocket.SetSocketOption(SocketOptionLevel.IP, 
                                    SocketOptionName.AddMembership, 
                                    mcastOption);
    
      } 

      catch (Exception e) 
      {
        Console.WriteLine(e.ToString());
      }
    }

    private static void
 ReceiveBroadcastMessages() 
    {
      bool done = false;
      byte[] bytes = new Byte[100];
      IPEndPoint groupEP = new IPEndPoint(mcastAddress, mcastPort);
      EndPoint remoteEP = (EndPoint) new IPEndPoint(IPAddress.Any
,0);
        
     
      try 
      {      
        while (!done) 
        {
          Console.WriteLine("Waiting for multicast packets.......");
          Console.WriteLine("Enter ^C to terminate.");

          mcastSocket.ReceiveFrom(bytes, ref remoteEP);

          Console.WriteLine("Received broadcast from {0} :\n {1}\n",
            groupEP.ToString(),
            Encoding.ASCII.GetString(bytes,0,bytes.Length));
          
          
        }

        mcastSocket.Close();
      } 

      catch (Exception e) 
      {
        Console.WriteLine(e.ToString());
      }
    }

    public static void Main(String[]
 args) 
    {
      // Initialize the multicast address group and multicast port.
      // Both address and port are selected from the allowed sets as
      // defined in the related RFC documents. These are the same 
      // as the values used by the sender.
      mcastAddress = IPAddress.Parse("224.168.100.2");
      mcastPort = 11000;
    
      // Start a multicast group.
      StartMulticast();
      
      // Display MulticastOption properties.
      MulticastOptionProperties();
      
      // Receive broadcast messages.
      ReceiveBroadcastMessages();
    }
  }
}
#using <System.dll>

using namespace System;
using namespace System::Net;
using namespace System::Net::Sockets;
using namespace System::Text;

// This program shows how to use the MultiCastOption type. In particular
,
// it shows how to use the MultiCastOption(IPAddress, IPAddress) constructor
,
// You need to use this constructor, in the case of multihomed host
 (i.e.,
// a host with more than one network card). With the first parameter
 you
// specify the multicast group address, with the second you specify
 the
// local address of one of the network cards you want to use for the
 data
// exchange.
// You must run this program in conjunction with the sender program
 as
// follows:
// Open a console window and run the listener from the command line.
// In another console window run the sender. In both cases you must
 specify
// the local IPAddress to use. To obtain this address run the ipconfig
 from
// the command line.
//
public ref class TestMulticastOption
{
private:
   static IPAddress^ mcastAddress;
   static int mcastPort;
   static Socket^ mcastSocket;
   static MulticastOption^ mcastOption;

   static void MulticastOptionProperties()
   {
      Console::WriteLine( "Current multicast group is: {0}", mcastOption->Group
 );
      Console::WriteLine( "Current multicast local address is: {0}", mcastOption->LocalAddress
 );
   }


   static void StartMulticast()
   {
      try
      {
         mcastSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Dgram,ProtocolType::Udp
 );
         Console::Write( "Enter the local IP Address: " );
         IPAddress^ localIPAddr = IPAddress::Parse( Console::ReadLine() );
         
         //IPAddress localIP = IPAddress::Any;
         EndPoint^ localEP = dynamic_cast<EndPoint^>(gcnew IPEndPoint( localIPAddr,mcastPort
 ));
         mcastSocket->Bind( localEP );
         
         // Define a MuticastOption object specifying the multicast
 group
         // address and the local IPAddress.
         // The multicast group address is the same one used by the
 server.
         mcastOption = gcnew MulticastOption( mcastAddress,localIPAddr );
         mcastSocket->SetSocketOption( SocketOptionLevel::IP, SocketOptionName::AddMembership,
 mcastOption );
         
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( e );
      }

   }

   static void ReceiveBrodcastMessages()
   {
      bool done = false;
      array<Byte>^bytes = gcnew array<Byte>(100);
      IPEndPoint^ groupEP = gcnew IPEndPoint( mcastAddress,mcastPort );
      EndPoint^ remoteEP = dynamic_cast<EndPoint^>(gcnew IPEndPoint( IPAddress::Any,0
 ));
      try
      {
         while (  !done )
         {
            Console::WriteLine( "Waiting for Multicast packets......."
 );
            Console::WriteLine( "Enter ^C to terminate." );
            mcastSocket->ReceiveFrom( bytes, remoteEP );
            Console::WriteLine( "Received broadcast from {0} :\n {1}\n",
 groupEP, Encoding::ASCII->GetString( bytes, 0, bytes->Length ) );
         }
         mcastSocket->Close();
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( e );
      }

   }


public:
   static void Main()
   {
      
      // Initialize multicast address group and multicast port.
      // Both address and port are selected from the allowed sets as
      // defined in the related RFC documents. These are the same values
      // used by the sender.
      mcastAddress = IPAddress::Parse( "224.168.100.2" );
      mcastPort = 11000;
      
      // Start a multicast group.
      StartMulticast();
      
      // Display multicast option properties.
      MulticastOptionProperties();
      
      // Receive brodcast messages.
      ReceiveBrodcastMessages();
   }

};

int main()
{
   TestMulticastOption::Main();
}

import System.* ;
import System.Net.* ;
import System.Net.Sockets.*;
import System.Text.*;

// This is the listener example that shows how to use the MulticastOption
  
// class.In particular, it shows how to use the MulticastOption 
// (IPAddress, IPAddress)constructor, which you need to use if you have
 a host 
// with more than one network card.
// The first parameter specifies the multicast group address, and the
 second 
// specifies the local address of the network card you want to use for
 the data
// exchange.
// You must run this program in conjunction with the sender program
 as 
// follows:
// Open a console window and run the listener from the command line.
 
// In another console window run the sender. In both cases you must
 specify 
// the local IPAddress to use. To obtain this address run the ipconfig
 comand
// from the command line. 
//  
public class TestMulticastOption
{
    private static IPAddress mcastAddress;
    private static int mcastPort;
    private static Socket mcastSocket;
    private static MulticastOption mcastOption;

    private static void
 MulticastOptionProperties()
    {
        Console.WriteLine(("Current multicast group is: " 
            + mcastOption.get_Group()));
        Console.WriteLine(("Current multicast local address is: " 
            + mcastOption.get_LocalAddress()));
    } //MulticastOptionProperties

    private static void
 StartMulticast()
    {
        try {
            mcastSocket = new Socket(AddressFamily.InterNetwork
,
                SocketType.Dgram, ProtocolType.Udp);
            Console.Write("Enter the local IP address: ");
            IPAddress localIPAddr = IPAddress.Parse(Console.ReadLine());

            //IPAddress localIP = IPAddress.Any;
            EndPoint localEP = 
                ((EndPoint)(new IPEndPoint(localIPAddr, mcastPort)));
            mcastSocket.Bind(localEP);

            // Define a MulticastOption object specifying the multicast
 group
            // address and the local IPAddress.
            // The multicast group address is the same as the
            // address used by the server.
            mcastOption = new MulticastOption(mcastAddress, localIPAddr);
            mcastSocket.SetSocketOption(SocketOptionLevel.IP,
                SocketOptionName.AddMembership, mcastOption);
        }
        catch (System.Exception e) {
            Console.WriteLine(e.ToString());
        }
    } //StartMulticast

    private static void
 ReceiveBroadcastMessages()
    {
        boolean done = false;
        System.Byte bytes[] = new System.Byte[100];
        IPEndPoint groupEP = new IPEndPoint(mcastAddress, mcastPort);
        EndPoint remoteEP = ((EndPoint)(new IPEndPoint(IPAddress.Any,
 0)));
        try {
            while (!(done)) {
                Console.WriteLine("Waiting for multicast
 packets.......");
                Console.WriteLine("Enter ^C to terminate.");
                mcastSocket.ReceiveFrom((ubyte[])bytes, remoteEP);
                Console.WriteLine("Received broadcast from {0} :\n {1}\n"
,
                    groupEP.ToString(), Encoding.get_ASCII().GetString(
                    (ubyte[])bytes, 0, bytes.length));
            }
            mcastSocket.Close();
        }
        catch (System.Exception e) {
            Console.WriteLine(e.ToString());
        }
    } //ReceiveBroadcastMessages

    public static void main(String[]
 args)
    {
        // Initialize the multicast address group and multicast port.
        // Both address and port are selected from the allowed sets
 as
        // defined in the related RFC documents. These are the same
 
        // as the values used by the sender.
        mcastAddress = IPAddress.Parse("224.168.100.2");
        mcastPort = 11000;

        // Start a multicast group.
        StartMulticast();

        // Display MulticastOption properties.
        MulticastOptionProperties();

        // Receive broadcast messages.
        ReceiveBroadcastMessages();
    } //main
} //TestMulticastOption   
' This sender example must be used in conjunction with the listener
 program.
' You must run this program as follows:
' Open a console window and run the listener from the command line.
 
' In another console window run the sender. In both cases you must specify
 
' the local IPAddress to use. To obtain this address, run the ipconfig
 command
' from the command line. 
'  
Imports System
Imports System.Net.Sockets
Imports System.Net
Imports System.Text
Imports Microsoft.VisualBasic

Namespace Mssc.TransportProtocols.Utilities

  Module M_TestMulticastOption

    Class TestMulticastOption

      Private Shared mcastAddress As
 IPAddress
      Private Shared mcastPort As
 Integer
      Private Shared mcastSocket As
 Socket


      Shared Sub JoinMulticastGroup()
        Try
          ' Create a multicast socket.
          mcastSocket = New Socket(AddressFamily.InterNetwork,
 SocketType.Dgram, ProtocolType.Udp)

          ' Get the local IP address used by the listener and the sender
 to
          ' exchange multicast messages. 
          Console.Write(ControlChars.Lf + "Enter local IPAddress
 for sending multicast packets: ")
          Dim localIPAddr As IPAddress = IPAddress.Parse(Console.ReadLine())

          ' Create an IPEndPoint object. 
          Dim IPlocal As New
 IPEndPoint(localIPAddr, 0)

          ' Bind this endpoint to the multicast socket.
          mcastSocket.Bind(IPlocal)

          ' Define a MulticastOption object specifying the multicast
 group 
          ' address and the local IP address.
          ' The multicast group address is the same as the address used
 by the listener.
          Dim mcastOption As MulticastOption
          mcastOption = New MulticastOption(mcastAddress, localIPAddr)

          mcastSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership,
 mcastOption)

        Catch e As Exception
          Console.WriteLine((ControlChars.Lf + e.ToString()))
        End Try
      End Sub 'JoinMulticast


      Shared Sub BroadcastMessage(ByVal
 message As String)
        Dim endPoint As IPEndPoint

        Try
          'Send multicast packets to the listener.
          endPoint = New IPEndPoint(mcastAddress, mcastPort)
          mcastSocket.SendTo(ASCIIEncoding.ASCII.GetBytes(message), endPoint)
          Console.WriteLine("Multicast data sent.....")
        Catch e As Exception
          Console.WriteLine((ControlChars.Lf + e.ToString()))
        End Try

        mcastSocket.Close()
      End Sub 'BrodcastMessage


      Public Shared Sub
 Main(ByVal args() As String)
        ' Initialize the multicast address group and multicast port.
        ' Both address and port are selected from the allowed sets as
        ' defined in the related RFC documents. These are the same as
 the 
        ' values used by the sender.
        mcastAddress = IPAddress.Parse("224.168.100.2")
        mcastPort = 11000

        ' Join the listener multicast group.
        JoinMulticastGroup()

        ' Broadcast the message to the listener.
        BroadcastMessage("Hello multicast listener.")
      End Sub 'Main
    End Class 'TestMulticastOption

  End Module

End Namespace
using System;
using System.Net.Sockets;
using System.Net;
using System.Text;

// This sender example must be used in conjunction with the listener
 program.
// You must run this program as follows:
// Open a console window and run the listener from the command line.
 
// In another console window run the sender. In both cases you must
 specify 
// the local IPAddress to use. To obtain this address,  run the ipconfig
 command 
// from the command line. 
//  
namespace Mssc.TransportProtocols.Utilities
{
  class TestMulticastOption
  {

    static IPAddress mcastAddress;
    static int mcastPort;
    static Socket mcastSocket;
   
    static void JoinMulticastGroup()
    {
      try
      {
        // Create a multicast socket.
        mcastSocket = new Socket(AddressFamily.InterNetwork, 
                                 SocketType.Dgram, 
                                 ProtocolType.Udp);
              
        // Get the local IP address used by the listener and the sender
 to
        // exchange multicast messages. 
        Console.Write("\nEnter local IPAddress for sending
 multicast packets: ");
        IPAddress  localIPAddr = IPAddress.Parse(Console.ReadLine());

        // Create an IPEndPoint object. 
        IPEndPoint IPlocal = new IPEndPoint(localIPAddr, 0);
        
        // Bind this endpoint to the multicast socket.
        mcastSocket.Bind(IPlocal);

        // Define a MulticastOption object specifying the multicast
 group 
        // address and the local IP address.
        // The multicast group address is the same as the address used
 by the listener.
        MulticastOption mcastOption;
        mcastOption = new MulticastOption(mcastAddress, localIPAddr);
        
        mcastSocket.SetSocketOption(SocketOptionLevel.IP, 
                                    SocketOptionName.AddMembership, 
                                    mcastOption);
     
      }
      catch (Exception e)
      {
        Console.WriteLine("\n" + e.ToString());
      }
    }

    static void BroadcastMessage(string
 message)
    {
      IPEndPoint endPoint;

      try
      {
        //Send multicast packets to the listener.
        endPoint = new IPEndPoint(mcastAddress,mcastPort);
        mcastSocket.SendTo(ASCIIEncoding.ASCII.GetBytes(message), endPoint);    
        
        Console.WriteLine("Multicast data sent.....");
      }
      catch (Exception e)
      {
        Console.WriteLine("\n" + e.ToString());
      }

      mcastSocket.Close();
    }
   
    
    static void Main(string[]
 args)
    {
      // Initialize the multicast address group and multicast port.
      // Both address and port are selected from the allowed sets as
      // defined in the related RFC documents. These are the same 
      // as the values used by the sender.
      mcastAddress = IPAddress.Parse("224.168.100.2");
      mcastPort = 11000;

      // Join the listener multicast group.
      JoinMulticastGroup();

      // Broadcast the message to the listener.
      BroadcastMessage("Hello multicast listener.");
    }
  }
}
#using <System.dll>

using namespace System;
using namespace System::Net::Sockets;
using namespace System::Net;
using namespace System::Text;

// This is an auxiliary program to be used in conjunction with a listener
// program.
// You must run this program as follows:
// Open a console window and run the listener from the command line.
// In another console window run the sender. In both cases you must
 specify
// the local IPAddress to use. To obtain this address run the ipconfig
// from the command line.
//
ref class TestMulticastOption
{
private:
   static IPAddress^ mcastAddress;
   static int mcastPort;
   static Socket^ mcastSocket;
   static void JoinMulticast()
   {
      try
      {
         
         // Create multicast socket.
         mcastSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Dgram,ProtocolType::Udp
 );
         
         // Get the local IP address used by the listener and the sender
 to
         // exchange data in a multicast fashion.
         Console::Write( "\nEnter local IPAddress for sending
 multicast packets: " );
         IPAddress^ localIPAddr = IPAddress::Parse( Console::ReadLine() );
         
         // Create an IPEndPoint Object*.
         IPEndPoint^ IPlocal = gcnew IPEndPoint( localIPAddr,0 );
         
         // Bind this end point to the multicast socket.
         mcastSocket->Bind( IPlocal );
         
         // Define a MuticastOption Object* specifying the multicast
 group
         // address and the local IPAddress.
         // The multicast group address is the same one used by the
 listener.
         MulticastOption^ mcastOption;
         mcastOption = gcnew MulticastOption( mcastAddress,localIPAddr );
         mcastSocket->SetSocketOption( SocketOptionLevel::IP, SocketOptionName::AddMembership,
 mcastOption );
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( "\n {0}", e );
      }

   }

   static void BrodcastMessage( String^ message
 )
   {
      IPEndPoint^ endPoint;
      try
      {
         
         //Send multicast packets to the listener.
         endPoint = gcnew IPEndPoint( mcastAddress,mcastPort );
         mcastSocket->SendTo( ASCIIEncoding::ASCII->GetBytes( message ), endPoint
 );
         Console::WriteLine( "Multicast data sent....." );
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( "\n {0}", e );
      }

      mcastSocket->Close();
   }


public:
   static void main()
   {
      
      // Initialize multicast address group and multicast port.
      // Both address and port are selected from the allowed sets as
      // defined in the related RFC documents. These are the same values
      // used by the sender.
      mcastAddress = IPAddress::Parse( "224.168.100.2" );
      mcastPort = 11000;
      
      // Join the listener multicast group.
      JoinMulticast();
      
      // Broadcast message to the listener.
      BrodcastMessage( "Hello multicast listener." );
   }

};

int main()
{
   TestMulticastOption::main();
}

継承階層継承階層
System.Object
  System.Net.Sockets.MulticastOption
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MulticastOption メンバ
System.Net.Sockets 名前空間

MulticastOption コンストラクタ (IPAddress, IPAddress)

MulticastOption クラス新しインスタンスを、指定した IP マルチキャスト グループ アドレスと、ネットワーク インターフェイス関連付けられたローカル IP アドレス使用して初期化します。

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

Dim group As IPAddress
Dim mcint As IPAddress

Dim instance As New MulticastOption(group,
 mcint)
public MulticastOption (
    IPAddress group,
    IPAddress mcint
)
public:
MulticastOption (
    IPAddress^ group, 
    IPAddress^ mcint
)
public MulticastOption (
    IPAddress group, 
    IPAddress mcint
)
public function MulticastOption (
    group : IPAddress, 
    mcint : IPAddress
)

パラメータ

group

グループ IPAddress

mcint

ローカル IPAddress

例外例外
例外種類条件

ArgumentNullException

groupnull 参照 (Visual Basic では Nothing) です。

または

mcintnull 参照 (Visual Basic では Nothing) です。

解説解説
使用例使用例

MulticastOption オブジェクト作成する例を次に示します

' Define a MulticastOption object specifying the multicast group 
' address and the local IPAddress.
' The multicast group address is the same as the address used by the
 server.
mcastOption = New MulticastOption(mcastAddress, localIPAddr)

mcastSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership,
 mcastOption)
 
// Define a MulticastOption object specifying the multicast group 
// address and the local IPAddress.
// The multicast group address is the same as the address used by the
 server.
mcastOption = new MulticastOption(mcastAddress, localIPAddr);

mcastSocket.SetSocketOption(SocketOptionLevel.IP, 
                            SocketOptionName.AddMembership, 
                            mcastOption);
// Define a MuticastOption object specifying the multicast group
// address and the local IPAddress.
// The multicast group address is the same one used by the server.
mcastOption = gcnew MulticastOption( mcastAddress,localIPAddr );
mcastSocket->SetSocketOption( SocketOptionLevel::IP, SocketOptionName::AddMembership,
 mcastOption );

// Define a MulticastOption object specifying the multicast group
// address and the local IPAddress.
// The multicast group address is the same as the
// address used by the server.
mcastOption = new MulticastOption(mcastAddress, localIPAddr);
mcastSocket.SetSocketOption(SocketOptionLevel.IP,
    SocketOptionName.AddMembership, mcastOption);
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MulticastOption クラス
MulticastOption メンバ
System.Net.Sockets 名前空間

MulticastOption コンストラクタ (IPAddress)

指定した IP マルチキャスト グループ用に、MulticastOption クラス新しバージョン初期化します。

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

例外例外
例外種類条件

ArgumentNullException

groupnull 参照 (Visual Basic では Nothing) です。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MulticastOption クラス
MulticastOption メンバ
System.Net.Sockets 名前空間

MulticastOption コンストラクタ (IPAddress, Int32)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

MulticastOption クラス新しインスタンスを、指定した IP マルチキャスト グループ アドレスインターフェイス インデックス使用して初期化します。

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

Public Sub New ( _
    group As IPAddress, _
    interfaceIndex As Integer _
)
Dim group As IPAddress
Dim interfaceIndex As Integer

Dim instance As New MulticastOption(group,
 interfaceIndex)
public MulticastOption (
    IPAddress group,
    int interfaceIndex
)
public:
MulticastOption (
    IPAddress^ group, 
    int interfaceIndex
)
public MulticastOption (
    IPAddress group, 
    int interfaceIndex
)
public function MulticastOption (
    group : IPAddress, 
    interfaceIndex : int
)

パラメータ

group

マルチキャスト グループIPAddress

interfaceIndex

このインターフェイスインデックスは、マルチキャスト パケット送受信使用されます。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MulticastOption クラス
MulticastOption メンバ
System.Net.Sockets 名前空間

MulticastOption コンストラクタ


MulticastOption プロパティ


MulticastOption メソッド


MulticastOption メンバ

マルチキャスト グループへの参加および参加取り消し使用する IPAddress の値を格納します

MulticastOption データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

MulticastOption クラス
System.Net.Sockets 名前空間


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

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

辞書ショートカット

すべての辞書の索引

「MulticastOption」の関連用語

MulticastOptionのお隣キーワード
検索ランキング

   

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



MulticastOptionのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS