SocketFlags Enumeration

SocketFlags Enumeration

Specifies socket send and receive behaviors.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

Namespace:  System.Net.Sockets
Assembly:  System (in System.dll)

<FlagsAttribute> _
Public Enumeration SocketFlags

Member nameDescription
NoneUse no flags for this call.
OutOfBandProcess out-of-band data.
PeekPeek at the incoming message.
DontRouteSend without using routing tables.
MaxIOVectorLengthProvides a standard value for the number of WSABUF structures that are used to send and receive data.
TruncatedThe message was too large to fit into the specified buffer and was truncated.
ControlDataTruncatedIndicates that the control data did not fit into an internal 64-KB buffer and was truncated.
BroadcastIndicates a broadcast packet.
MulticastIndicates a multicast packet.
PartialPartial send or receive for message.

The following example sends data and specifies None for SocketFlags.

' Displays sending with a connected socket
' using the overload that takes a buffer, message size, and socket flags.
Public Shared Function SendReceiveTest3(ByVal server As Socket) As Integer 
    Dim msg As Byte() = Encoding.UTF8.GetBytes("This is a test")
    Dim bytes(255) As Byte
        ' Blocks until send returns.
        Dim i As Integer = server.Send(msg, msg.Length, SocketFlags.None)
        Console.WriteLine("Sent {0} bytes.", i)

        ' Get reply from the server.
        Dim byteCount As Integer = server.Receive(bytes, server.Available, SocketFlags.None)
        If byteCount > 0 Then
        End If
    Catch e As SocketException
        Console.WriteLine("{0} Error code: {1}.", e.Message, e.ErrorCode)
        Return e.ErrorCode
    End Try
    Return 0

End Function 'SendReceiveTest3

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

© 2016 Microsoft