SocketFlags Énumération

Définition

Spécifie les comportements d'envoi et de réception du socket.Specifies socket send and receive behaviors.

Cette énumération a un attribut FlagsAttribute qui permet une combinaison au niveau du bit de ses valeurs membres.

public enum class SocketFlags
public enum SocketFlags
[System.Flags]
public enum SocketFlags
type SocketFlags = 
[<System.Flags>]
type SocketFlags = 
Public Enum SocketFlags
Héritage
SocketFlags
Attributs

Champs

Broadcast 1024

Indique un paquet de diffusion.Indicates a broadcast packet.

ControlDataTruncated 512

Indique que les données de contrôle ne tenaient pas dans une mémoire tampon de 64 Ko interne et ont été tronquées.Indicates that the control data did not fit into an internal 64-KB buffer and was truncated.

DontRoute 4

Envoyer sans utiliser de tables de routage.Send without using routing tables.

MaxIOVectorLength 16

Fournit une valeur standard pour le nombre de structures WSABUF utilisées pour envoyer et recevoir des données.Provides a standard value for the number of WSABUF structures that are used to send and receive data. Cette valeur n’est pas utilisée ou n'est pas prise en charge sur .NET Framework 4.5.NET Framework 4.5.This value is not used or supported on .NET Framework 4.5.NET Framework 4.5.

Multicast 2048

Indique un paquet de multidiffusion.Indicates a multicast packet.

None 0

N’utiliser aucun indicateur pour cet appel.Use no flags for this call.

OutOfBand 1

Traiter les données hors bande.Process out-of-band data.

Partial 32768

Envoyer ou recevoir partiellement un message.Partial send or receive for message.

Peek 2

Lire le message entrant.Peek at the incoming message.

Truncated 256

Le message était trop grand pour tenir dans la mémoire tampon spécifiée et a été tronqué.The message was too large to fit into the specified buffer and was truncated.

Exemples

L’exemple suivant envoie des données et spécifie SocketFlags.None .The following example sends data and specifies 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, 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);
        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

S’applique à