SocketFlags Wyliczenie

Definicja

Określa zachowania wysyłania i odbierania gniazd.

To wyliczenie obsługuje bitową kombinację jego wartości składowych.

public enum class SocketFlags
[System.Flags]
public enum SocketFlags
[<System.Flags>]
type SocketFlags = 
Public Enum SocketFlags
Dziedziczenie
SocketFlags
Atrybuty

Pola

Broadcast 1024

Wskazuje pakiet emisji.

ControlDataTruncated 512

Wskazuje, że dane sterujące nie mieściły się w wewnętrznym buforze 64 KB i zostały obcięte.

DontRoute 4

Wyślij bez użycia tabel routingu.

MaxIOVectorLength 16

Zapewnia standardową wartość dla liczby struktur WSABUF, które są używane do wysyłania i odbierania danych. Ta wartość nie jest używana ani obsługiwana w .NET Framework 4.5.

Multicast 2048

Wskazuje pakiet multiemisji.

None 0

Nie używaj flag dla tego wywołania.

OutOfBand 1

Przetwarzanie danych poza pasmem.

Partial 32768

Częściowe wysyłanie lub odbieranie wiadomości.

Peek 2

Zajrzyj do wiadomości przychodzącej.

Truncated 256

Komunikat był zbyt duży, aby zmieścić się w określonym buforze i został obcięty.

Przykłady

Poniższy przykład wysyła dane i określa .SocketFlags.None

// Displays sending with a connected socket
// using the overload that takes a buffer, message size, and socket flags.
int SendReceiveTest3( Socket^ server )
{
   array<Byte>^ msg = Encoding::UTF8->GetBytes( "This is a test" );
   array<Byte>^ bytes = gcnew array<Byte>(256);
   try
   {
      // Blocks until send returns.
      int i = server->Send( msg, msg->Length, SocketFlags::None );
      Console::WriteLine( "Sent {0} bytes.", i.ToString() );
      
      // Get reply from the server.
      int byteCount = server->Receive( bytes, server->Available,
         SocketFlags::None );
      if ( byteCount > 0 )
      {
         Console::WriteLine( Encoding::UTF8->GetString( bytes ) );
      }
   }
   catch ( SocketException^ e ) 
   {
      Console::WriteLine( "{0} Error code: {1}.", e->Message, e->ErrorCode.ToString() );
      return (e->ErrorCode);
   }
   return 0;
}
// Displays sending with a connected socket
// using the overload that takes a buffer, message size, and socket flags.
public static int SendReceiveTest3(Socket server)
{
    byte[] msg = Encoding.UTF8.GetBytes("This is a test");
    byte[] bytes = new byte[256];
    try
    {
        // Blocks until send returns.
        int i = server.Send(msg, msg.Length, SocketFlags.None);
        Console.WriteLine("Sent {0} bytes.", i);

        // Get reply from the server.
        int byteCount = server.Receive(bytes, bytes.Length, SocketFlags.None);
        if (byteCount > 0)
            Console.WriteLine(Encoding.UTF8.GetString(bytes, 0, byteCount));
    }
    catch (SocketException e)
    {
        Console.WriteLine("{0} Error code: {1}.", e.Message, e.ErrorCode);
        return (e.ErrorCode);
    }
    return 0;
}
' 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
    Try
        ' 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
            Console.WriteLine(Encoding.UTF8.GetString(bytes))
        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

Dotyczy