ProtocolType Property

Socket.ProtocolType Property

Gets the protocol type of the Socket.

[Visual Basic]
Public ReadOnly Property ProtocolType As ProtocolType
[C#]
public ProtocolType ProtocolType {get;}
[C++]
public: __property ProtocolType get_ProtocolType();
[JScript]
public function get ProtocolType() : ProtocolType;

Property Value

One of the ProtocolType values.

Remarks

The ProtocolType property is set when the Socket is created, and specifies the protocol used by that Socket.

Example

[Visual Basic, C#, C++] The following example displays the AddressFamily, SocketType, and ProtocolType to the console.

[Visual Basic] 
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()))


[C#] 
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 ());


[C++] 
Socket *s = new 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 = ");
Console::Write(__box(s->AddressFamily)->ToString());
Console::Write("\nSocketType = ");
Console::Write(__box(s->SocketType)->ToString());
Console::Write("\nProtocolType = ");
Console::WriteLine(__box(s->ProtocolType)->ToString());

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Socket Class | Socket Members | System.Net.Sockets Namespace

Show:
© 2016 Microsoft