Socket.ProtocolType 屬性

定義

取得 Socket 的通訊協定 (Protocol) 類型。

public:
 property System::Net::Sockets::ProtocolType ProtocolType { System::Net::Sockets::ProtocolType get(); };
public System.Net.Sockets.ProtocolType ProtocolType { get; }
member this.ProtocolType : System.Net.Sockets.ProtocolType
Public ReadOnly Property ProtocolType As ProtocolType

屬性值

其中一個 ProtocolType 值。

範例

下列程式代碼範例會顯示 AddressFamilySocketTypeProtocolType 到 主控台。

Socket^ s = gcnew Socket(lep->Address->AddressFamily, SocketType::Stream, ProtocolType::Tcp);

// Uses the AddressFamily, SocketType, and ProtocolType properties.
Console::Write("I just set the following properties of socket: \n");
Console::Write("Address Family = {0}", s->AddressFamily.ToString());
Console::Write("\nSocketType = {0}", s->SocketType.ToString());
Console::WriteLine("\nProtocolType = {0}", s->ProtocolType.ToString());
Socket s = new Socket(lep.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

// Using the AddressFamily, SocketType, and ProtocolType properties.
Console.WriteLine("I just set the following properties of socket: " + "Address Family = " + s.AddressFamily.ToString() + "\nSocketType = " + s.SocketType.ToString() + "\nProtocolType = " + s.ProtocolType.ToString());
Dim s As New Socket(lep.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp)

'Using the AddressFamily, SocketType, and ProtocolType properties.
Console.WriteLine(("I just set the following properties of socket: " + "Address Family = " + s.AddressFamily.ToString() + ControlChars.Cr + "SocketType = " + s.SocketType.ToString() + ControlChars.Cr + "ProtocolType = " + s.ProtocolType.ToString()))

備註

建立 時SocketProtocolType設定 屬性,並指定該 Socket所使用的通訊協定。

適用於