Leggere in inglese

Condividi tramite


SocketFlags Enumerazione

Definizione

Specifica i comportamenti di invio e ricezione di socket.

Questa enumerazione supporta una combinazione bit per bit dei rispettivi valori dei membri.

C#
[System.Flags]
public enum SocketFlags
Ereditarietà
SocketFlags
Attributi

Campi

Nome Valore Descrizione
Broadcast 1024

Indica un pacchetto broadcast.

ControlDataTruncated 512

Indica che i dati del controllo non rientravano nel buffer interno a 64 KB e sono stati troncati.

DontRoute 4

Invia senza usare tabelle di routing.

MaxIOVectorLength 16

Fornisce un valore standard per il numero di strutture WSABUF usate per inviare e ricevere dati. Questo valore non viene usato o supportato in .NET Framework 4.5.

Multicast 2048

Indica un pacchetto multicast.

None 0

Non usa flag per questa chiamata.

OutOfBand 1

Elabora dati fuori banda.

Partial 32768

Invia o riceve parzialmente il messaggio.

Peek 2

Legge il messaggio in entrata.

Truncated 256

Il messaggio era troppo grande per rientrare nel buffer specificato ed è stato troncato.

Esempio

Nell'esempio seguente vengono inviati dati e viene specificato SocketFlags.None.

C#
// 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;
}

Si applica a

Prodotto Versioni
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1