SocketFlags Enumerazione
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Specifica i comportamenti di invio e ricezione del socket.
Questa enumerazione supporta una combinazione bit per bit dei rispettivi valori dei membri.
public enum class SocketFlags
[System.Flags]
public enum SocketFlags
[<System.Flags>]
type SocketFlags =
Public Enum SocketFlags
- Ereditarietà
- Attributi
Campi
| Nome | Valore | Descrizione |
|---|---|---|
| None | 0 | Non usare flag per questa chiamata. |
| OutOfBand | 1 | Elaborare i dati fuori banda. |
| Peek | 2 | Visualizzare il messaggio in arrivo. |
| DontRoute | 4 | Inviare senza usare le tabelle di routing. |
| MaxIOVectorLength | 16 | Fornisce un valore standard per il numero di strutture WSABUF utilizzate per inviare e ricevere dati. Questo valore non viene usato o supportato in .NET Framework 4.5. |
| Truncated | 256 | Il messaggio era troppo grande per rientrare nel buffer specificato ed è stato troncato. |
| ControlDataTruncated | 512 | Indica che i dati del controllo non sono stati inseriti in un buffer interno di 64 KB ed è stato troncato. |
| Broadcast | 1024 | Indica un pacchetto broadcast. |
| Multicast | 2048 | Indica un pacchetto multicast. |
| Partial | 32768 | Invio parziale o ricezione per il messaggio. |
Esempio
Nell'esempio seguente vengono inviati dati e viene SocketFlags.Nonespecificato .
// 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