This documentation is archived and is not being maintained.

Socket.SocketType Property

Gets the type of the Socket.

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

Property Value

One of the SocketType values.

Remarks

SocketType is read-only and is set when the Socket is created.

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 | SocketType

Show: