Socket Socket Socket Socket Class

Definição

Implementa a interface de soquetes Berkeley.Implements the Berkeley sockets interface.

public ref class Socket : IDisposable
public class Socket : IDisposable
type Socket = class
    interface IDisposable
Public Class Socket
Implements IDisposable
Herança
SocketSocketSocketSocket
Implementações

Exemplos

O exemplo de código a seguir mostra Socket como a classe pode ser usada para enviar dados a um servidor http e receber a resposta.The following code example shows how the Socket class can be used to send data to an HTTP server and receive the response. Este exemplo é bloqueado até que a página inteira seja recebida.This example blocks until the entire page is received.

#using <System.dll>

using namespace System;
using namespace System::Text;
using namespace System::IO;
using namespace System::Net;
using namespace System::Net::Sockets;
using namespace System::Collections;
Socket^ ConnectSocket( String^ server, int port )
{
   Socket^ s = nullptr;
   IPHostEntry^ hostEntry = nullptr;
   
   // Get host related information.
   hostEntry = Dns::Resolve( server );
   
   // Loop through the AddressList to obtain the supported AddressFamily. This is to avoid
   // an exception that occurs when the host IP Address is not compatible with the address family
   // (typical in the IPv6 case).
   IEnumerator^ myEnum = hostEntry->AddressList->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      IPAddress^ address = safe_cast<IPAddress^>(myEnum->Current);
      IPEndPoint^ endPoint = gcnew IPEndPoint( address,port );
      Socket^ tmpS = gcnew Socket( endPoint->AddressFamily,SocketType::Stream,ProtocolType::Tcp );
      tmpS->Connect( endPoint );
      if ( tmpS->Connected )
      {
         s = tmpS;
         break;
      }
      else
      {
         continue;
      }
   }

   return s;
}

// This method requests the home page content for the specified server.
String^ SocketSendReceive( String^ server, int port )
{
   String^ request = String::Concat( "GET / HTTP/1.1\r\nHost: ", server, "\r\nConnection: Close\r\n\r\n" );
   array<Byte>^bytesSent = Encoding::ASCII->GetBytes( request );
   array<Byte>^bytesReceived = gcnew array<Byte>(256);
   String^ strRetPage = "";
   
   // Create a socket connection with the specified server and port.
   Socket^ s = ConnectSocket( server, port );
   if ( s == nullptr )
      return ("Connection failed");
   
   // Send request to the server.
   s->Send( bytesSent, bytesSent->Length, static_cast<SocketFlags>(0) );
   
   // Receive the server home page content.
   int bytes = 0;
   strRetPage = String::Concat( "Default HTML page on ", server, ":\r\n" );
   do
   {
      bytes = s->Receive( bytesReceived, bytesReceived->Length, static_cast<SocketFlags>(0) );
      strRetPage = String::Concat( strRetPage, Encoding::ASCII->GetString( bytesReceived, 0, bytes ) );
   }
   while ( bytes > 0 );
   
   s->Dispose();

   return strRetPage;
}

int main()
{
   array<String^>^args = Environment::GetCommandLineArgs();
   String^ host;
   int port = 80;
   if ( args->Length == 1 )
      
   // If no server name is passed as argument to this program, 
   // use the current host name as default.
   host = Dns::GetHostName();
   else
      host = args[ 1 ];

   String^ result = SocketSendReceive( host, port );
   Console::WriteLine( result );
}
using System;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;

public class GetSocket
{
    private static Socket ConnectSocket(string server, int port)
    {
        Socket s = null;
        IPHostEntry hostEntry = null;
        
        // Get host related information.
        hostEntry = Dns.GetHostEntry(server);

        // Loop through the AddressList to obtain the supported AddressFamily. This is to avoid
        // an exception that occurs when the host IP Address is not compatible with the address family
        // (typical in the IPv6 case).
        foreach(IPAddress address in hostEntry.AddressList)
        {
            IPEndPoint ipe = new IPEndPoint(address, port);
            Socket tempSocket = 
                new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

            tempSocket.Connect(ipe);

            if(tempSocket.Connected)
            {
                s = tempSocket;
                break;
            }
            else
            {
                continue;
            }
        }
        return s;
    }

    // This method requests the home page content for the specified server.
    private static string SocketSendReceive(string server, int port) 
    {
        string request = "GET / HTTP/1.1\r\nHost: " + server + 
            "\r\nConnection: Close\r\n\r\n";
        Byte[] bytesSent = Encoding.ASCII.GetBytes(request);
        Byte[] bytesReceived = new Byte[256];
        string page = "";
        
        // Create a socket connection with the specified server and port.
        using(Socket s = ConnectSocket(server, port)) {

            if (s == null)
                return ("Connection failed");
        
            // Send request to the server.
            s.Send(bytesSent, bytesSent.Length, 0);  
            
            // Receive the server home page content.
            int bytes = 0;
            page = "Default HTML page on " + server + ":\r\n";

            // The following will block until the page is transmitted.
            do {
                bytes = s.Receive(bytesReceived, bytesReceived.Length, 0);
                page = page + Encoding.ASCII.GetString(bytesReceived, 0, bytes);
            }
            while (bytes > 0);
        }
        
        return page;
    }
    
    public static void Main(string[] args) 
    {
        string host;
        int port = 80;

        if (args.Length == 0)
            // If no server name is passed as argument to this program, 
            // use the current host name as the default.
            host = Dns.GetHostName();
        else
            host = args[0];

        string result = SocketSendReceive(host, port); 
        Console.WriteLine(result);
    }
}

Imports System
Imports System.Text
Imports System.IO
Imports System.Net
Imports System.Net.Sockets
Imports Microsoft.VisualBasic

Public Class GetSocket
   
   Private Shared Function ConnectSocket(server As String, port As Integer) As Socket
      Dim s As Socket = Nothing
      Dim hostEntry As IPHostEntry = Nothing      
     
         ' Get host related information.
        hostEntry = Dns.GetHostEntry(server)
         
         ' Loop through the AddressList to obtain the supported AddressFamily. This is to avoid
         ' an exception that occurs when the host host IP Address is not compatible with the address family
         ' (typical in the IPv6 case).
      Dim address As IPAddress
 
        For Each address In  hostEntry.AddressList
            Dim endPoint As New IPEndPoint(address, port)
            Dim tempSocket As New Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
      
            tempSocket.Connect(endPoint)
            
            If tempSocket.Connected Then
               s = tempSocket
               Exit For
            End If

         Next address
      
      Return s
   End Function
   
   ' This method requests the home page content for the specified server.
   
   Private Shared Function SocketSendReceive(server As String, port As Integer) As String
      'Set up variables and String to write to the server.
      Dim ascii As Encoding = Encoding.ASCII
      Dim request As String = "GET / HTTP/1.1" + ControlChars.Cr + ControlChars.Lf + "Host: " + server + ControlChars.Cr + ControlChars.Lf + "Connection: Close" + ControlChars.Cr + ControlChars.Lf + ControlChars.Cr + ControlChars.Lf
      Dim bytesSent As [Byte]() = ascii.GetBytes(request)
      Dim bytesReceived(255) As [Byte]
      Dim page As String = ""  
      
      ' Create a socket connection with the specified server and port.
      Dim s As Socket = ConnectSocket(server, port)
      
      If s Is Nothing Then
         Return "Connection failed"
      End If 
      ' Send request to the server.
      s.Send(bytesSent, bytesSent.Length, 0)
      
      ' Receive the server  home page content.
      Dim bytes As Int32
      
      ' Read the first 256 bytes.
      page = "Default HTML page on " + server + ":" + ControlChars.Cr + ControlChars.Lf
      
      ' The following will block until the page is transmitted.
      Do
         bytes = s.Receive(bytesReceived, bytesReceived.Length, 0)
            page = page + Encoding.ASCII.GetString(bytesReceived, 0, bytes)
      Loop While bytes > 0
      
      Return page
   End Function 
   
   'Entry point which delegates to C-style main Private Function
   Public Overloads Shared Sub Main()
      Main(System.Environment.GetCommandLineArgs())
   End Sub
   
   Overloads Private Shared Sub Main(args() As String)
      Dim host As String
      Dim port As Integer = 80
      
      If args.Length = 1 Then
         ' If no server name is passed as argument to this program, 
         ' use the current host name as default.
         host = Dns.GetHostName()
      Else
         host = args(1)
      End If 
      
      Dim result As String = SocketSendReceive(host, port)
      
      Console.WriteLine(result)
   End Sub 'Main
End Class  

Comentários

A Socket classe fornece um conjunto avançado de métodos e propriedades para comunicações de rede.The Socket class provides a rich set of methods and properties for network communications. A Socket classe permite que você execute a transferência de dados síncrona e assíncrona usando qualquer um dos protocolos de comunicação ProtocolType listados na enumeração.The Socket class allows you to perform both synchronous and asynchronous data transfer using any of the communication protocols listed in the ProtocolType enumeration.

A Socket classe segue o padrão de nomenclatura de .NET Framework para métodos assíncronos.The Socket class follows the .NET Framework naming pattern for asynchronous methods. Por exemplo, o método Receive síncrono corresponde aos métodos assíncronos EndReceive BeginReceive e.For example, the synchronous Receive method corresponds to the asynchronous BeginReceive and EndReceive methods.

Se seu aplicativo exigir apenas um thread durante a execução, use os métodos a seguir, que são projetados para o modo de operação síncrona.If your application only requires one thread during execution, use the following methods, which are designed for synchronous operation mode.

  • Se você estiver usando um protocolo orientado por conexão, como TCP, o servidor poderá escutar conexões usando o Listen método.If you are using a connection-oriented protocol such as TCP, your server can listen for connections using the Listen method. O Accept método processa todas as solicitações de conexão de entrada Socket e retorna um que você pode usar para comunicar dados com o host remoto.The Accept method processes any incoming connection requests and returns a Socket that you can use to communicate data with the remote host. Use isso retornado Socket para chamar o Send método Receive ou.Use this returned Socket to call the Send or Receive method. Chame o Bind método antes de chamar o Listen método se você quiser especificar o endereço IP local e o número da porta.Call the Bind method prior to calling the Listen method if you want to specify the local IP address and port number. Use um número de porta zero se desejar que o provedor de serviços subjacente atribua uma porta gratuita para você.Use a port number of zero if you want the underlying service provider to assign a free port for you. Se você quiser se conectar a um host de escuta, chame Connect o método.If you want to connect to a listening host, call the Connect method. Para comunicar dados, chame o Send método Receive ou.To communicate data, call the Send or Receive method.

  • Se você estiver usando um protocolo sem conexão como UDP, não será necessário escutar conexões.If you are using a connectionless protocol such as UDP, you do not need to listen for connections at all. Chame o ReceiveFrom método para aceitar os datagramas de entrada.Call the ReceiveFrom method to accept any incoming datagrams. Use o SendTo método para enviar datagrams para um host remoto.Use the SendTo method to send datagrams to a remote host.

Para processar as comunicações usando threads separados durante a execução, use os métodos a seguir, que são projetados para o modo de operação assíncrona.To process communications using separate threads during execution, use the following methods, which are designed for asynchronous operation mode.

Se você executar várias operações assíncronas em um soquete, elas não serão necessariamente concluídas na ordem em que foram iniciadas.If you perform multiple asynchronous operations on a socket, they do not necessarily complete in the order in which they are started.

Quando terminar de enviar e receber dados, use o Shutdown método para desabilitar o. SocketWhen you are finished sending and receiving data, use the Shutdown method to disable the Socket. Depois de Shutdownchamar, chame Close o método para liberar Sockettodos os recursos associados ao.After calling Shutdown, call the Close method to release all resources associated with the Socket.

A Socket classe permite que você Socket configure o usando o SetSocketOption método.The Socket class allows you to configure your Socket using the SetSocketOption method. Recupere essas configurações usando o GetSocketOption método.Retrieve these settings using the GetSocketOption method.

Observação

Se você estiver escrevendo um aplicativo relativamente simples e não precisar de desempenho máximo, considere usar TcpClient, TcpListenere UdpClient.If you are writing a relatively simple application and do not require maximum performance, consider using TcpClient, TcpListener, and UdpClient. Essas classes fornecem uma interface mais simples e mais amigável para Socket comunicações.These classes provide a simpler and more user-friendly interface to Socket communications.

Construtores

Socket(AddressFamily, SocketType, ProtocolType) Socket(AddressFamily, SocketType, ProtocolType) Socket(AddressFamily, SocketType, ProtocolType) Socket(AddressFamily, SocketType, ProtocolType)

Inicializa uma nova instância da classe Socket usando a família de endereços, o tipo de soquete e o protocolo especificados.Initializes a new instance of the Socket class using the specified address family, socket type and protocol.

Socket(SocketInformation) Socket(SocketInformation) Socket(SocketInformation) Socket(SocketInformation)

Inicializa uma nova instância da classe Socket, usando o valor especificado de DuplicateAndClose(Int32).Initializes a new instance of the Socket class using the specified value returned from DuplicateAndClose(Int32).

Socket(SocketType, ProtocolType) Socket(SocketType, ProtocolType) Socket(SocketType, ProtocolType) Socket(SocketType, ProtocolType)

Inicializa uma nova instância da classe Socket usando o tipo de soquete e o protocolo especificados.Initializes a new instance of the Socket class using the specified socket type and protocol.

Propriedades

AddressFamily AddressFamily AddressFamily AddressFamily

Obtém a família de endereços do Socket.Gets the address family of the Socket.

Available Available Available Available

Obtém a quantidade de dados recebidos da rede e disponíveis para leitura.Gets the amount of data that has been received from the network and is available to be read.

Blocking Blocking Blocking Blocking

Obtém ou define um valor que indica se o Socket está no modo de bloqueio.Gets or sets a value that indicates whether the Socket is in blocking mode.

Connected Connected Connected Connected

Obtém um valor que indica se um Socket está conectado a um host remoto desde a última operação Send ou Receive.Gets a value that indicates whether a Socket is connected to a remote host as of the last Send or Receive operation.

DontFragment DontFragment DontFragment DontFragment

Obtém ou define um valor Boolean que especifica se o Socket permite que datagramas de protocolo IP sejam fragmentados.Gets or sets a Boolean value that specifies whether the Socket allows Internet Protocol (IP) datagrams to be fragmented.

DualMode DualMode DualMode DualMode

Obtém ou define um valor de Boolean que especifica se o Socket é um soquete de modo duplo, usado para IPv4 e IPv6.Gets or sets a Boolean value that specifies whether the Socket is a dual-mode socket used for both IPv4 and IPv6.

EnableBroadcast EnableBroadcast EnableBroadcast EnableBroadcast

Obtém ou define um valor Boolean que especifica se o Socket pode enviar ou receber pacotes de difusão.Gets or sets a Boolean value that specifies whether the Socket can send or receive broadcast packets.

ExclusiveAddressUse ExclusiveAddressUse ExclusiveAddressUse ExclusiveAddressUse

Obtém ou define um valor Boolean que especifica se o Socket permite que um único processo se associe a uma porta.Gets or sets a Boolean value that specifies whether the Socket allows only one process to bind to a port.

Handle Handle Handle Handle

Obtém o identificador de sistema operacional do Socket.Gets the operating system handle for the Socket.

IsBound IsBound IsBound IsBound

Obtém um valor que indica se o Socket está associado a uma porta local específica.Gets a value that indicates whether the Socket is bound to a specific local port.

LingerState LingerState LingerState LingerState

Obtém ou define um valor que especifica se o Socket atrasará ao fechar um soquete em uma tentativa de enviar todos os dados pendentes.Gets or sets a value that specifies whether the Socket will delay closing a socket in an attempt to send all pending data.

LocalEndPoint LocalEndPoint LocalEndPoint LocalEndPoint

Obtém o ponto de extremidade local.Gets the local endpoint.

MulticastLoopback MulticastLoopback MulticastLoopback MulticastLoopback

Obtém ou define um valor que especifica se os pacotes de multicast de saída são entregues para o aplicativo de envio.Gets or sets a value that specifies whether outgoing multicast packets are delivered to the sending application.

NoDelay NoDelay NoDelay NoDelay

Obtém ou define um valor Boolean que especifica se o Socket do fluxo está usando o Algoritmo de Nagle.Gets or sets a Boolean value that specifies whether the stream Socket is using the Nagle algorithm.

OSSupportsIPv4 OSSupportsIPv4 OSSupportsIPv4 OSSupportsIPv4

Indica se o sistema operacional subjacente e os adaptadores de rede dão suporte ao IPv4 (protocolo IP versão 4).Indicates whether the underlying operating system and network adaptors support Internet Protocol version 4 (IPv4).

OSSupportsIPv6 OSSupportsIPv6 OSSupportsIPv6 OSSupportsIPv6

Indica se o sistema operacional subjacente e os adaptadores de rede dão suporte ao IPv6 (protocolo IP versão 6).Indicates whether the underlying operating system and network adaptors support Internet Protocol version 6 (IPv6).

ProtocolType ProtocolType ProtocolType ProtocolType

Obtém o tipo de protocolo do Socket.Gets the protocol type of the Socket.

ReceiveBufferSize ReceiveBufferSize ReceiveBufferSize ReceiveBufferSize

Obtém ou define um valor que especifica o tamanho do buffer de recepção do Socket.Gets or sets a value that specifies the size of the receive buffer of the Socket.

ReceiveTimeout ReceiveTimeout ReceiveTimeout ReceiveTimeout

Obtém ou define um valor que especifica o tempo após o qual uma chamada Receive síncrona atingirá o tempo limite.Gets or sets a value that specifies the amount of time after which a synchronous Receive call will time out.

RemoteEndPoint RemoteEndPoint RemoteEndPoint RemoteEndPoint

Obtém o ponto de extremidade remoto.Gets the remote endpoint.

SafeHandle SafeHandle SafeHandle SafeHandle

Obtém um SafeSocketHandle que representa o identificador do soquete que o objeto Socket atual encapsula.Gets a SafeSocketHandle that represents the socket handle that the current Socket object encapsulates.

SendBufferSize SendBufferSize SendBufferSize SendBufferSize

Obtém ou define um valor que especifica o tamanho do buffer de envio do Socket.Gets or sets a value that specifies the size of the send buffer of the Socket.

SendTimeout SendTimeout SendTimeout SendTimeout

Obtém ou define um valor que especifica o tempo após o qual uma chamada Send síncrona atingirá o tempo limite.Gets or sets a value that specifies the amount of time after which a synchronous Send call will time out.

SocketType SocketType SocketType SocketType

Obtém o tipo do Socket.Gets the type of the Socket.

SupportsIPv4 SupportsIPv4 SupportsIPv4 SupportsIPv4

Obtém um valor que indica se o suporte para IPv4 está disponível e habilitado no host atual.Gets a value indicating whether IPv4 support is available and enabled on the current host.

SupportsIPv6 SupportsIPv6 SupportsIPv6 SupportsIPv6

Obtém um valor que indica se o Framework dá suporte a IPv6 para determinados membros Dns obsoletos.Gets a value that indicates whether the Framework supports IPv6 for certain obsolete Dns members.

Ttl Ttl Ttl Ttl

Obtém ou define um valor que especifica o valor TTL (vida útil) de pacotes IP (Protocolo de Internet) enviados pelo Socket.Gets or sets a value that specifies the Time To Live (TTL) value of Internet Protocol (IP) packets sent by the Socket.

UseOnlyOverlappedIO UseOnlyOverlappedIO UseOnlyOverlappedIO UseOnlyOverlappedIO

Especifica se o soquete deve usar apenas o modo de E/S Sobreposta.Specifies whether the socket should only use Overlapped I/O mode.

Métodos

Accept() Accept() Accept() Accept()

Cria um novo Socket para uma conexão recém-criada.Creates a new Socket for a newly created connection.

AcceptAsync(SocketAsyncEventArgs) AcceptAsync(SocketAsyncEventArgs) AcceptAsync(SocketAsyncEventArgs) AcceptAsync(SocketAsyncEventArgs)

Inicia uma operação assíncrona para aceitar uma tentativa de conexão de entrada.Begins an asynchronous operation to accept an incoming connection attempt.

BeginAccept(AsyncCallback, Object) BeginAccept(AsyncCallback, Object) BeginAccept(AsyncCallback, Object) BeginAccept(AsyncCallback, Object)

Inicia uma operação assíncrona para aceitar uma tentativa de conexão de entrada.Begins an asynchronous operation to accept an incoming connection attempt.

BeginAccept(Int32, AsyncCallback, Object) BeginAccept(Int32, AsyncCallback, Object) BeginAccept(Int32, AsyncCallback, Object) BeginAccept(Int32, AsyncCallback, Object)

Inicia uma operação assíncrona para aceitar uma tentativa de conexão de entrada e recebe o primeiro bloco de dados enviado pelo aplicativo cliente.Begins an asynchronous operation to accept an incoming connection attempt and receives the first block of data sent by the client application.

BeginAccept(Socket, Int32, AsyncCallback, Object) BeginAccept(Socket, Int32, AsyncCallback, Object) BeginAccept(Socket, Int32, AsyncCallback, Object) BeginAccept(Socket, Int32, AsyncCallback, Object)

Inicia uma operação assíncrona para aceitar uma tentativa de conexão de entrada de um soquete especificado e recebe o primeiro bloco de dados enviado pelo aplicativo cliente.Begins an asynchronous operation to accept an incoming connection attempt from a specified socket and receives the first block of data sent by the client application.

BeginConnect(EndPoint, AsyncCallback, Object) BeginConnect(EndPoint, AsyncCallback, Object) BeginConnect(EndPoint, AsyncCallback, Object) BeginConnect(EndPoint, AsyncCallback, Object)

Inicia uma solicitação assíncrona para uma conexão de host remoto.Begins an asynchronous request for a remote host connection.

BeginConnect(IPAddress, Int32, AsyncCallback, Object) BeginConnect(IPAddress, Int32, AsyncCallback, Object) BeginConnect(IPAddress, Int32, AsyncCallback, Object) BeginConnect(IPAddress, Int32, AsyncCallback, Object)

Inicia uma solicitação assíncrona para uma conexão de host remoto.Begins an asynchronous request for a remote host connection. O host é especificado por um IPAddress e um número da porta.The host is specified by an IPAddress and a port number.

BeginConnect(IPAddress[], Int32, AsyncCallback, Object) BeginConnect(IPAddress[], Int32, AsyncCallback, Object) BeginConnect(IPAddress[], Int32, AsyncCallback, Object) BeginConnect(IPAddress[], Int32, AsyncCallback, Object)

Inicia uma solicitação assíncrona para uma conexão de host remoto.Begins an asynchronous request for a remote host connection. O host é especificado por uma matriz IPAddress e um número da porta.The host is specified by an IPAddress array and a port number.

BeginConnect(String, Int32, AsyncCallback, Object) BeginConnect(String, Int32, AsyncCallback, Object) BeginConnect(String, Int32, AsyncCallback, Object) BeginConnect(String, Int32, AsyncCallback, Object)

Inicia uma solicitação assíncrona para uma conexão de host remoto.Begins an asynchronous request for a remote host connection. O host é especificado por um nome do host e um número da porta.The host is specified by a host name and a port number.

BeginDisconnect(Boolean, AsyncCallback, Object) BeginDisconnect(Boolean, AsyncCallback, Object) BeginDisconnect(Boolean, AsyncCallback, Object) BeginDisconnect(Boolean, AsyncCallback, Object)

Inicia uma solicitação assíncrona para se desconectar de um ponto de extremidade remoto.Begins an asynchronous request to disconnect from a remote endpoint.

BeginReceive(Byte[], Int32, Int32, SocketFlags, AsyncCallback, Object) BeginReceive(Byte[], Int32, Int32, SocketFlags, AsyncCallback, Object) BeginReceive(Byte[], Int32, Int32, SocketFlags, AsyncCallback, Object) BeginReceive(Byte[], Int32, Int32, SocketFlags, AsyncCallback, Object)

Começa a receber de maneira assíncrona dados de um Socket conectado.Begins to asynchronously receive data from a connected Socket.

BeginReceive(Byte[], Int32, Int32, SocketFlags, SocketError, AsyncCallback, Object) BeginReceive(Byte[], Int32, Int32, SocketFlags, SocketError, AsyncCallback, Object) BeginReceive(Byte[], Int32, Int32, SocketFlags, SocketError, AsyncCallback, Object) BeginReceive(Byte[], Int32, Int32, SocketFlags, SocketError, AsyncCallback, Object)

Começa a receber de maneira assíncrona dados de um Socket conectado.Begins to asynchronously receive data from a connected Socket.

BeginReceive(IList<ArraySegment<Byte>>, SocketFlags, AsyncCallback, Object) BeginReceive(IList<ArraySegment<Byte>>, SocketFlags, AsyncCallback, Object) BeginReceive(IList<ArraySegment<Byte>>, SocketFlags, AsyncCallback, Object) BeginReceive(IList<ArraySegment<Byte>>, SocketFlags, AsyncCallback, Object)

Começa a receber de maneira assíncrona dados de um Socket conectado.Begins to asynchronously receive data from a connected Socket.

BeginReceive(IList<ArraySegment<Byte>>, SocketFlags, SocketError, AsyncCallback, Object) BeginReceive(IList<ArraySegment<Byte>>, SocketFlags, SocketError, AsyncCallback, Object) BeginReceive(IList<ArraySegment<Byte>>, SocketFlags, SocketError, AsyncCallback, Object) BeginReceive(IList<ArraySegment<Byte>>, SocketFlags, SocketError, AsyncCallback, Object)

Começa a receber de maneira assíncrona dados de um Socket conectado.Begins to asynchronously receive data from a connected Socket.

BeginReceiveFrom(Byte[], Int32, Int32, SocketFlags, EndPoint, AsyncCallback, Object) BeginReceiveFrom(Byte[], Int32, Int32, SocketFlags, EndPoint, AsyncCallback, Object) BeginReceiveFrom(Byte[], Int32, Int32, SocketFlags, EndPoint, AsyncCallback, Object) BeginReceiveFrom(Byte[], Int32, Int32, SocketFlags, EndPoint, AsyncCallback, Object)

Começa a receber dados de um dispositivo de rede especificado de maneira assíncrona.Begins to asynchronously receive data from a specified network device.

BeginReceiveMessageFrom(Byte[], Int32, Int32, SocketFlags, EndPoint, AsyncCallback, Object) BeginReceiveMessageFrom(Byte[], Int32, Int32, SocketFlags, EndPoint, AsyncCallback, Object) BeginReceiveMessageFrom(Byte[], Int32, Int32, SocketFlags, EndPoint, AsyncCallback, Object) BeginReceiveMessageFrom(Byte[], Int32, Int32, SocketFlags, EndPoint, AsyncCallback, Object)

Inicia o recebimento de forma assíncrona do número especificado de bytes de dados no local especificado do buffer de dados, usando o SocketFlags especificado e armazena as informações de ponto de extremidade e de pacote.Begins to asynchronously receive the specified number of bytes of data into the specified location of the data buffer, using the specified SocketFlags, and stores the endpoint and packet information.

BeginSend(Byte[], Int32, Int32, SocketFlags, AsyncCallback, Object) BeginSend(Byte[], Int32, Int32, SocketFlags, AsyncCallback, Object) BeginSend(Byte[], Int32, Int32, SocketFlags, AsyncCallback, Object) BeginSend(Byte[], Int32, Int32, SocketFlags, AsyncCallback, Object)

Envia dados de forma assíncrona para um Socket conectado.Sends data asynchronously to a connected Socket.

BeginSend(Byte[], Int32, Int32, SocketFlags, SocketError, AsyncCallback, Object) BeginSend(Byte[], Int32, Int32, SocketFlags, SocketError, AsyncCallback, Object) BeginSend(Byte[], Int32, Int32, SocketFlags, SocketError, AsyncCallback, Object) BeginSend(Byte[], Int32, Int32, SocketFlags, SocketError, AsyncCallback, Object)

Envia dados de forma assíncrona para um Socket conectado.Sends data asynchronously to a connected Socket.

BeginSend(IList<ArraySegment<Byte>>, SocketFlags, AsyncCallback, Object) BeginSend(IList<ArraySegment<Byte>>, SocketFlags, AsyncCallback, Object) BeginSend(IList<ArraySegment<Byte>>, SocketFlags, AsyncCallback, Object) BeginSend(IList<ArraySegment<Byte>>, SocketFlags, AsyncCallback, Object)

Envia dados de forma assíncrona para um Socket conectado.Sends data asynchronously to a connected Socket.

BeginSend(IList<ArraySegment<Byte>>, SocketFlags, SocketError, AsyncCallback, Object) BeginSend(IList<ArraySegment<Byte>>, SocketFlags, SocketError, AsyncCallback, Object) BeginSend(IList<ArraySegment<Byte>>, SocketFlags, SocketError, AsyncCallback, Object) BeginSend(IList<ArraySegment<Byte>>, SocketFlags, SocketError, AsyncCallback, Object)

Envia dados de forma assíncrona para um Socket conectado.Sends data asynchronously to a connected Socket.

BeginSendFile(String, AsyncCallback, Object) BeginSendFile(String, AsyncCallback, Object) BeginSendFile(String, AsyncCallback, Object) BeginSendFile(String, AsyncCallback, Object)

Envia o arquivo fileName para um objeto Socket conectado usando o sinalizador UseDefaultWorkerThread.Sends the file fileName to a connected Socket object using the UseDefaultWorkerThread flag.

BeginSendFile(String, Byte[], Byte[], TransmitFileOptions, AsyncCallback, Object) BeginSendFile(String, Byte[], Byte[], TransmitFileOptions, AsyncCallback, Object) BeginSendFile(String, Byte[], Byte[], TransmitFileOptions, AsyncCallback, Object) BeginSendFile(String, Byte[], Byte[], TransmitFileOptions, AsyncCallback, Object)

Envia um arquivo e buffers de dados de forma assíncrona para um objeto Socket conectado.Sends a file and buffers of data asynchronously to a connected Socket object.

BeginSendTo(Byte[], Int32, Int32, SocketFlags, EndPoint, AsyncCallback, Object) BeginSendTo(Byte[], Int32, Int32, SocketFlags, EndPoint, AsyncCallback, Object) BeginSendTo(Byte[], Int32, Int32, SocketFlags, EndPoint, AsyncCallback, Object) BeginSendTo(Byte[], Int32, Int32, SocketFlags, EndPoint, AsyncCallback, Object)

Envia dados de maneira assíncrona para um host remoto específico.Sends data asynchronously to a specific remote host.

Bind(EndPoint) Bind(EndPoint) Bind(EndPoint) Bind(EndPoint)

Associa um Socket a um ponto de extremidade local.Associates a Socket with a local endpoint.

CancelConnectAsync(SocketAsyncEventArgs) CancelConnectAsync(SocketAsyncEventArgs) CancelConnectAsync(SocketAsyncEventArgs) CancelConnectAsync(SocketAsyncEventArgs)

Cancela uma solicitação assíncrona de uma conexão de host remoto.Cancels an asynchronous request for a remote host connection.

Close() Close() Close() Close()

Fecha a conexão Socket e libera todos os recursos associados.Closes the Socket connection and releases all associated resources.

Close(Int32) Close(Int32) Close(Int32) Close(Int32)

Fecha a conexão de Socket e libera todos os recursos associados com um tempo limite especificado para permitir que os dados em fila sejam enviados.Closes the Socket connection and releases all associated resources with a specified timeout to allow queued data to be sent.

Connect(EndPoint) Connect(EndPoint) Connect(EndPoint) Connect(EndPoint)

Estabelece uma conexão com o host remoto.Establishes a connection to a remote host.

Connect(IPAddress, Int32) Connect(IPAddress, Int32) Connect(IPAddress, Int32) Connect(IPAddress, Int32)

Estabelece uma conexão com o host remoto.Establishes a connection to a remote host. O host é especificado por um endereço IP e um número da porta.The host is specified by an IP address and a port number.

Connect(IPAddress[], Int32) Connect(IPAddress[], Int32) Connect(IPAddress[], Int32) Connect(IPAddress[], Int32)

Estabelece uma conexão com o host remoto.Establishes a connection to a remote host. O host é especificado por uma matriz de endereços IP e um número da porta.The host is specified by an array of IP addresses and a port number.

Connect(String, Int32) Connect(String, Int32) Connect(String, Int32) Connect(String, Int32)

Estabelece uma conexão com o host remoto.Establishes a connection to a remote host. O host é especificado por um nome do host e um número da porta.The host is specified by a host name and a port number.

ConnectAsync(SocketAsyncEventArgs) ConnectAsync(SocketAsyncEventArgs) ConnectAsync(SocketAsyncEventArgs) ConnectAsync(SocketAsyncEventArgs)

Inicia uma solicitação assíncrona para uma conexão com um host remoto.Begins an asynchronous request for a connection to a remote host.

ConnectAsync(SocketType, ProtocolType, SocketAsyncEventArgs) ConnectAsync(SocketType, ProtocolType, SocketAsyncEventArgs) ConnectAsync(SocketType, ProtocolType, SocketAsyncEventArgs) ConnectAsync(SocketType, ProtocolType, SocketAsyncEventArgs)

Inicia uma solicitação assíncrona para uma conexão com um host remoto.Begins an asynchronous request for a connection to a remote host.

Disconnect(Boolean) Disconnect(Boolean) Disconnect(Boolean) Disconnect(Boolean)

Fecha a conexão de soquete e permite a reutilização do soquete.Closes the socket connection and allows reuse of the socket.

DisconnectAsync(SocketAsyncEventArgs) DisconnectAsync(SocketAsyncEventArgs) DisconnectAsync(SocketAsyncEventArgs) DisconnectAsync(SocketAsyncEventArgs)

Inicia uma solicitação assíncrona para se desconectar de um ponto de extremidade remoto.Begins an asynchronous request to disconnect from a remote endpoint.

Dispose() Dispose() Dispose() Dispose()

Libera todos os recursos usados pela instância atual da classe Socket.Releases all resources used by the current instance of the Socket class.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Libera os recursos não gerenciados usados pelo Socket e, opcionalmente, descarta os recursos gerenciados.Releases the unmanaged resources used by the Socket, and optionally disposes of the managed resources.

DuplicateAndClose(Int32) DuplicateAndClose(Int32) DuplicateAndClose(Int32) DuplicateAndClose(Int32)

Duplica a referência de soquete para o processo de destino e fecha o soquete para esse processo.Duplicates the socket reference for the target process, and closes the socket for this process.

EndAccept(Byte[], IAsyncResult) EndAccept(Byte[], IAsyncResult) EndAccept(Byte[], IAsyncResult) EndAccept(Byte[], IAsyncResult)

Aceita de forma assíncrona uma tentativa de conexão de entrada e cria um novo objeto Socket para manipular as comunicações de host remoto.Asynchronously accepts an incoming connection attempt and creates a new Socket object to handle remote host communication. Esse método retorna um buffer que contém os dados iniciais transferidos.This method returns a buffer that contains the initial data transferred.

EndAccept(Byte[], Int32, IAsyncResult) EndAccept(Byte[], Int32, IAsyncResult) EndAccept(Byte[], Int32, IAsyncResult) EndAccept(Byte[], Int32, IAsyncResult)

Aceita de forma assíncrona uma tentativa de conexão de entrada e cria um novo objeto Socket para manipular as comunicações de host remoto.Asynchronously accepts an incoming connection attempt and creates a new Socket object to handle remote host communication. Esse método retorna um buffer que contém os dados iniciais e o número de bytes transferidos.This method returns a buffer that contains the initial data and the number of bytes transferred.

EndAccept(IAsyncResult) EndAccept(IAsyncResult) EndAccept(IAsyncResult) EndAccept(IAsyncResult)

Aceita de forma assíncrona uma tentativa de conexão de entrada e cria um novo Socket para manipular as comunicações com o host remoto.Asynchronously accepts an incoming connection attempt and creates a new Socket to handle remote host communication.

EndConnect(IAsyncResult) EndConnect(IAsyncResult) EndConnect(IAsyncResult) EndConnect(IAsyncResult)

Encerra uma solicitação de conexão assíncrona pendente.Ends a pending asynchronous connection request.

EndDisconnect(IAsyncResult) EndDisconnect(IAsyncResult) EndDisconnect(IAsyncResult) EndDisconnect(IAsyncResult)

Encerra uma solicitação de desconexão assíncrona pendente.Ends a pending asynchronous disconnect request.

EndReceive(IAsyncResult) EndReceive(IAsyncResult) EndReceive(IAsyncResult) EndReceive(IAsyncResult)

Encerra uma leitura assíncrona pendente.Ends a pending asynchronous read.

EndReceive(IAsyncResult, SocketError) EndReceive(IAsyncResult, SocketError) EndReceive(IAsyncResult, SocketError) EndReceive(IAsyncResult, SocketError)

Encerra uma leitura assíncrona pendente.Ends a pending asynchronous read.

EndReceiveFrom(IAsyncResult, EndPoint) EndReceiveFrom(IAsyncResult, EndPoint) EndReceiveFrom(IAsyncResult, EndPoint) EndReceiveFrom(IAsyncResult, EndPoint)

Termina uma leitura assíncrona pendente de um ponto de extremidade específico.Ends a pending asynchronous read from a specific endpoint.

EndReceiveMessageFrom(IAsyncResult, SocketFlags, EndPoint, IPPacketInformation) EndReceiveMessageFrom(IAsyncResult, SocketFlags, EndPoint, IPPacketInformation) EndReceiveMessageFrom(IAsyncResult, SocketFlags, EndPoint, IPPacketInformation) EndReceiveMessageFrom(IAsyncResult, SocketFlags, EndPoint, IPPacketInformation)

Termina uma leitura assíncrona pendente de um ponto de extremidade específico.Ends a pending asynchronous read from a specific endpoint. Esse método também revela mais informações sobre o pacote que EndReceiveFrom(IAsyncResult, EndPoint).This method also reveals more information about the packet than EndReceiveFrom(IAsyncResult, EndPoint).

EndSend(IAsyncResult) EndSend(IAsyncResult) EndSend(IAsyncResult) EndSend(IAsyncResult)

Encerra um envio assíncrono pendente.Ends a pending asynchronous send.

EndSend(IAsyncResult, SocketError) EndSend(IAsyncResult, SocketError) EndSend(IAsyncResult, SocketError) EndSend(IAsyncResult, SocketError)

Encerra um envio assíncrono pendente.Ends a pending asynchronous send.

EndSendFile(IAsyncResult) EndSendFile(IAsyncResult) EndSendFile(IAsyncResult) EndSendFile(IAsyncResult)

Encerra um envio assíncrono pendente de um arquivo.Ends a pending asynchronous send of a file.

EndSendTo(IAsyncResult) EndSendTo(IAsyncResult) EndSendTo(IAsyncResult) EndSendTo(IAsyncResult)

Encerra um envio assíncrono pendente para um local específico.Ends a pending asynchronous send to a specific location.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

Libera os recursos usados pela classe Socket.Frees resources used by the Socket class.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Retorna um valor de hash para uma instância de Socket.Returns a hash value for a Socket instance.

GetSocketOption(SocketOptionLevel, SocketOptionName) GetSocketOption(SocketOptionLevel, SocketOptionName) GetSocketOption(SocketOptionLevel, SocketOptionName) GetSocketOption(SocketOptionLevel, SocketOptionName)

Retorna o valor de uma opção Socket especificada, representada como um objeto.Returns the value of a specified Socket option, represented as an object.

GetSocketOption(SocketOptionLevel, SocketOptionName, Byte[]) GetSocketOption(SocketOptionLevel, SocketOptionName, Byte[]) GetSocketOption(SocketOptionLevel, SocketOptionName, Byte[]) GetSocketOption(SocketOptionLevel, SocketOptionName, Byte[])

Retorna a opção da configuração Socket especificada, representada como uma matriz de bytes.Returns the specified Socket option setting, represented as a byte array.

GetSocketOption(SocketOptionLevel, SocketOptionName, Int32) GetSocketOption(SocketOptionLevel, SocketOptionName, Int32) GetSocketOption(SocketOptionLevel, SocketOptionName, Int32) GetSocketOption(SocketOptionLevel, SocketOptionName, Int32)

Retorna o valor da opção Socket especificada em uma matriz.Returns the value of the specified Socket option in an array.

GetType() GetType() GetType() GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Inherited from Object)
IOControl(Int32, Byte[], Byte[]) IOControl(Int32, Byte[], Byte[]) IOControl(Int32, Byte[], Byte[]) IOControl(Int32, Byte[], Byte[])

Define os modos de operação de nível inferior do Socket usando códigos de controle numéricos.Sets low-level operating modes for the Socket using numerical control codes.

IOControl(IOControlCode, Byte[], Byte[]) IOControl(IOControlCode, Byte[], Byte[]) IOControl(IOControlCode, Byte[], Byte[]) IOControl(IOControlCode, Byte[], Byte[])

Define modos de operação de nível inferior do Socket usando a enumeração IOControlCode para especificar códigos de controle.Sets low-level operating modes for the Socket using the IOControlCode enumeration to specify control codes.

Listen(Int32) Listen(Int32) Listen(Int32) Listen(Int32)

Coloca um Socket em um estado de escuta.Places a Socket in a listening state.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Inherited from Object)
Poll(Int32, SelectMode) Poll(Int32, SelectMode) Poll(Int32, SelectMode) Poll(Int32, SelectMode)

Determina o status do Socket.Determines the status of the Socket.

Receive(Byte[]) Receive(Byte[]) Receive(Byte[]) Receive(Byte[])

Recebe dados de um Socket associado em um buffer de recepção.Receives data from a bound Socket into a receive buffer.

Receive(Byte[], Int32, Int32, SocketFlags) Receive(Byte[], Int32, Int32, SocketFlags) Receive(Byte[], Int32, Int32, SocketFlags) Receive(Byte[], Int32, Int32, SocketFlags)

Recebe o número de bytes especificado de um Socket associado na posição de deslocamento especificada do buffer de recepção usando o SocketFlags especificado.Receives the specified number of bytes from a bound Socket into the specified offset position of the receive buffer, using the specified SocketFlags.

Receive(Byte[], Int32, Int32, SocketFlags, SocketError) Receive(Byte[], Int32, Int32, SocketFlags, SocketError) Receive(Byte[], Int32, Int32, SocketFlags, SocketError) Receive(Byte[], Int32, Int32, SocketFlags, SocketError)

Recebe dados de um Socket associado em um buffer de recepção, usando o SocketFlags especificado.Receives data from a bound Socket into a receive buffer, using the specified SocketFlags.

Receive(Byte[], Int32, SocketFlags) Receive(Byte[], Int32, SocketFlags) Receive(Byte[], Int32, SocketFlags) Receive(Byte[], Int32, SocketFlags)

Recebe o número de bytes especificado de dados de um Socket associado em um buffer de recepção, usando o SocketFlags especificado.Receives the specified number of bytes of data from a bound Socket into a receive buffer, using the specified SocketFlags.

Receive(Byte[], SocketFlags) Receive(Byte[], SocketFlags) Receive(Byte[], SocketFlags) Receive(Byte[], SocketFlags)

Recebe dados de um Socket associado em um buffer de recepção, usando o SocketFlags especificado.Receives data from a bound Socket into a receive buffer, using the specified SocketFlags.

Receive(IList<ArraySegment<Byte>>) Receive(IList<ArraySegment<Byte>>) Receive(IList<ArraySegment<Byte>>) Receive(IList<ArraySegment<Byte>>)

Recebe dados de um Socket associado na lista de buffers de recepção.Receives data from a bound Socket into the list of receive buffers.

Receive(IList<ArraySegment<Byte>>, SocketFlags) Receive(IList<ArraySegment<Byte>>, SocketFlags) Receive(IList<ArraySegment<Byte>>, SocketFlags) Receive(IList<ArraySegment<Byte>>, SocketFlags)

Recebe dados de um Socket associado na lista de buffers de recepção, usando o SocketFlags especificado.Receives data from a bound Socket into the list of receive buffers, using the specified SocketFlags.

Receive(IList<ArraySegment<Byte>>, SocketFlags, SocketError) Receive(IList<ArraySegment<Byte>>, SocketFlags, SocketError) Receive(IList<ArraySegment<Byte>>, SocketFlags, SocketError) Receive(IList<ArraySegment<Byte>>, SocketFlags, SocketError)

Recebe dados de um Socket associado na lista de buffers de recepção, usando o SocketFlags especificado.Receives data from a bound Socket into the list of receive buffers, using the specified SocketFlags.

Receive(Span<Byte>) Receive(Span<Byte>) Receive(Span<Byte>) Receive(Span<Byte>)
Receive(Span<Byte>, SocketFlags) Receive(Span<Byte>, SocketFlags) Receive(Span<Byte>, SocketFlags) Receive(Span<Byte>, SocketFlags)
Receive(Span<Byte>, SocketFlags, SocketError) Receive(Span<Byte>, SocketFlags, SocketError) Receive(Span<Byte>, SocketFlags, SocketError) Receive(Span<Byte>, SocketFlags, SocketError)
ReceiveAsync(SocketAsyncEventArgs) ReceiveAsync(SocketAsyncEventArgs) ReceiveAsync(SocketAsyncEventArgs) ReceiveAsync(SocketAsyncEventArgs)

Inicia uma solicitação assíncrona para receber dados de um objeto Socket conectado.Begins an asynchronous request to receive data from a connected Socket object.

ReceiveFrom(Byte[], EndPoint) ReceiveFrom(Byte[], EndPoint) ReceiveFrom(Byte[], EndPoint) ReceiveFrom(Byte[], EndPoint)

Recebe um datagrama no buffer de dados e armazena o ponto de extremidade.Receives a datagram into the data buffer and stores the endpoint.

ReceiveFrom(Byte[], Int32, Int32, SocketFlags, EndPoint) ReceiveFrom(Byte[], Int32, Int32, SocketFlags, EndPoint) ReceiveFrom(Byte[], Int32, Int32, SocketFlags, EndPoint) ReceiveFrom(Byte[], Int32, Int32, SocketFlags, EndPoint)

Recebe o número de bytes de dados no local especificado no buffer de dados usando o SocketFlags especificado e armazena o ponto de extremidade.Receives the specified number of bytes of data into the specified location of the data buffer, using the specified SocketFlags, and stores the endpoint.

ReceiveFrom(Byte[], Int32, SocketFlags, EndPoint) ReceiveFrom(Byte[], Int32, SocketFlags, EndPoint) ReceiveFrom(Byte[], Int32, SocketFlags, EndPoint) ReceiveFrom(Byte[], Int32, SocketFlags, EndPoint)

Recebe o número especificado de bytes no buffer de dados usando o SocketFlags especificado e armazena o ponto de extremidade.Receives the specified number of bytes into the data buffer, using the specified SocketFlags, and stores the endpoint.

ReceiveFrom(Byte[], SocketFlags, EndPoint) ReceiveFrom(Byte[], SocketFlags, EndPoint) ReceiveFrom(Byte[], SocketFlags, EndPoint) ReceiveFrom(Byte[], SocketFlags, EndPoint)

Recebe um datagrama no buffer de dados, usando o SocketFlags especificado e armazena o ponto de extremidade.Receives a datagram into the data buffer, using the specified SocketFlags, and stores the endpoint.

ReceiveFromAsync(SocketAsyncEventArgs) ReceiveFromAsync(SocketAsyncEventArgs) ReceiveFromAsync(SocketAsyncEventArgs) ReceiveFromAsync(SocketAsyncEventArgs)

Começa a receber dados de um dispositivo de rede especificado de maneira assíncrona.Begins to asynchronously receive data from a specified network device.

ReceiveMessageFrom(Byte[], Int32, Int32, SocketFlags, EndPoint, IPPacketInformation) ReceiveMessageFrom(Byte[], Int32, Int32, SocketFlags, EndPoint, IPPacketInformation) ReceiveMessageFrom(Byte[], Int32, Int32, SocketFlags, EndPoint, IPPacketInformation) ReceiveMessageFrom(Byte[], Int32, Int32, SocketFlags, EndPoint, IPPacketInformation)

Recebe o número de bytes de dados no local especificado no buffer de dados usando o SocketFlags especificado e armazena as informações de ponto de extremidade e pacote.Receives the specified number of bytes of data into the specified location of the data buffer, using the specified SocketFlags, and stores the endpoint and packet information.

ReceiveMessageFromAsync(SocketAsyncEventArgs) ReceiveMessageFromAsync(SocketAsyncEventArgs) ReceiveMessageFromAsync(SocketAsyncEventArgs) ReceiveMessageFromAsync(SocketAsyncEventArgs)

Inicia o recebimento de forma assíncrona do número especificado de bytes de dados no local especificado do buffer de dados, usando o SocketFlags especificado e armazena as informações de ponto de extremidade e de pacote.Begins to asynchronously receive the specified number of bytes of data into the specified location in the data buffer, using the specified SocketFlags, and stores the endpoint and packet information.

Select(IList, IList, IList, Int32) Select(IList, IList, IList, Int32) Select(IList, IList, IList, Int32) Select(IList, IList, IList, Int32)

Determina o status de um ou mais soquetes.Determines the status of one or more sockets.

Send(Byte[]) Send(Byte[]) Send(Byte[]) Send(Byte[])

Envia dados para um Socket conectado.Sends data to a connected Socket.

Send(Byte[], Int32, Int32, SocketFlags) Send(Byte[], Int32, Int32, SocketFlags) Send(Byte[], Int32, Int32, SocketFlags) Send(Byte[], Int32, Int32, SocketFlags)

Envia o número especificado de bytes de dados para um Socket conectado, começando no deslocamento especificado e usando os SocketFlags especificados.Sends the specified number of bytes of data to a connected Socket, starting at the specified offset, and using the specified SocketFlags.

Send(Byte[], Int32, Int32, SocketFlags, SocketError) Send(Byte[], Int32, Int32, SocketFlags, SocketError) Send(Byte[], Int32, Int32, SocketFlags, SocketError) Send(Byte[], Int32, Int32, SocketFlags, SocketError)

Envia o número especificado de bytes de dados a um Socket conectado, iniciando no deslocamento especificado e usando o SocketFlags especificadoSends the specified number of bytes of data to a connected Socket, starting at the specified offset, and using the specified SocketFlags

Send(Byte[], Int32, SocketFlags) Send(Byte[], Int32, SocketFlags) Send(Byte[], Int32, SocketFlags) Send(Byte[], Int32, SocketFlags)

Envia o número especificado de bytes de dados para um Socket conectado, usando o SocketFlags especificado.Sends the specified number of bytes of data to a connected Socket, using the specified SocketFlags.

Send(Byte[], SocketFlags) Send(Byte[], SocketFlags) Send(Byte[], SocketFlags) Send(Byte[], SocketFlags)

Envia dados para um Socket conectado usando o SocketFlags especificado.Sends data to a connected Socket using the specified SocketFlags.

Send(IList<ArraySegment<Byte>>) Send(IList<ArraySegment<Byte>>) Send(IList<ArraySegment<Byte>>) Send(IList<ArraySegment<Byte>>)

Envia o conjunto de buffers na lista para um Socket conectado.Sends the set of buffers in the list to a connected Socket.

Send(IList<ArraySegment<Byte>>, SocketFlags) Send(IList<ArraySegment<Byte>>, SocketFlags) Send(IList<ArraySegment<Byte>>, SocketFlags) Send(IList<ArraySegment<Byte>>, SocketFlags)

Envia o conjunto de buffers na lista para um Socket conectado, usando o SocketFlags especificado.Sends the set of buffers in the list to a connected Socket, using the specified SocketFlags.

Send(IList<ArraySegment<Byte>>, SocketFlags, SocketError) Send(IList<ArraySegment<Byte>>, SocketFlags, SocketError) Send(IList<ArraySegment<Byte>>, SocketFlags, SocketError) Send(IList<ArraySegment<Byte>>, SocketFlags, SocketError)

Envia o conjunto de buffers na lista para um Socket conectado, usando o SocketFlags especificado.Sends the set of buffers in the list to a connected Socket, using the specified SocketFlags.

Send(ReadOnlySpan<Byte>) Send(ReadOnlySpan<Byte>) Send(ReadOnlySpan<Byte>) Send(ReadOnlySpan<Byte>)
Send(ReadOnlySpan<Byte>, SocketFlags) Send(ReadOnlySpan<Byte>, SocketFlags) Send(ReadOnlySpan<Byte>, SocketFlags) Send(ReadOnlySpan<Byte>, SocketFlags)
Send(ReadOnlySpan<Byte>, SocketFlags, SocketError) Send(ReadOnlySpan<Byte>, SocketFlags, SocketError) Send(ReadOnlySpan<Byte>, SocketFlags, SocketError) Send(ReadOnlySpan<Byte>, SocketFlags, SocketError)
SendAsync(SocketAsyncEventArgs) SendAsync(SocketAsyncEventArgs) SendAsync(SocketAsyncEventArgs) SendAsync(SocketAsyncEventArgs)

Envia dados de forma assíncrona para um objeto Socket conectado.Sends data asynchronously to a connected Socket object.

SendFile(String) SendFile(String) SendFile(String) SendFile(String)

Envia o arquivo fileName para um objeto Socket conectado com o sinalizador de transmissão UseDefaultWorkerThread.Sends the file fileName to a connected Socket object with the UseDefaultWorkerThread transmit flag.

SendFile(String, Byte[], Byte[], TransmitFileOptions) SendFile(String, Byte[], Byte[], TransmitFileOptions) SendFile(String, Byte[], Byte[], TransmitFileOptions) SendFile(String, Byte[], Byte[], TransmitFileOptions)

Envia o arquivo fileName e buffers de dados a um Socket conectado usando o valor TransmitFileOptions especificado.Sends the file fileName and buffers of data to a connected Socket object using the specified TransmitFileOptions value.

SendPacketsAsync(SocketAsyncEventArgs) SendPacketsAsync(SocketAsyncEventArgs) SendPacketsAsync(SocketAsyncEventArgs) SendPacketsAsync(SocketAsyncEventArgs)

Envia uma coleção de arquivos ou buffers de dados na memória assincronamente para um objeto Socket conectado.Sends a collection of files or in memory data buffers asynchronously to a connected Socket object.

SendTo(Byte[], EndPoint) SendTo(Byte[], EndPoint) SendTo(Byte[], EndPoint) SendTo(Byte[], EndPoint)

Envia dados ao ponto de extremidade especificado.Sends data to the specified endpoint.

SendTo(Byte[], Int32, Int32, SocketFlags, EndPoint) SendTo(Byte[], Int32, Int32, SocketFlags, EndPoint) SendTo(Byte[], Int32, Int32, SocketFlags, EndPoint) SendTo(Byte[], Int32, Int32, SocketFlags, EndPoint)

Envia o número especificado de bytes de dados para o ponto de extremidade especificado, começando no local especificado no buffer e usando o SocketFlags especificado.Sends the specified number of bytes of data to the specified endpoint, starting at the specified location in the buffer, and using the specified SocketFlags.

SendTo(Byte[], Int32, SocketFlags, EndPoint) SendTo(Byte[], Int32, SocketFlags, EndPoint) SendTo(Byte[], Int32, SocketFlags, EndPoint) SendTo(Byte[], Int32, SocketFlags, EndPoint)

Envia o número especificado de bytes de dados para um ponto de extremidade especificado usando o SocketFlags especificado.Sends the specified number of bytes of data to the specified endpoint using the specified SocketFlags.

SendTo(Byte[], SocketFlags, EndPoint) SendTo(Byte[], SocketFlags, EndPoint) SendTo(Byte[], SocketFlags, EndPoint) SendTo(Byte[], SocketFlags, EndPoint)

Envia dados para um ponto de extremidade específico usando o SocketFlags especificado.Sends data to a specific endpoint using the specified SocketFlags.

SendToAsync(SocketAsyncEventArgs) SendToAsync(SocketAsyncEventArgs) SendToAsync(SocketAsyncEventArgs) SendToAsync(SocketAsyncEventArgs)

Envia dados de maneira assíncrona para um host remoto específico.Sends data asynchronously to a specific remote host.

SetIPProtectionLevel(IPProtectionLevel) SetIPProtectionLevel(IPProtectionLevel) SetIPProtectionLevel(IPProtectionLevel) SetIPProtectionLevel(IPProtectionLevel)

Defina o nível de proteção IP em um soquete.Set the IP protection level on a socket.

SetSocketOption(SocketOptionLevel, SocketOptionName, Boolean) SetSocketOption(SocketOptionLevel, SocketOptionName, Boolean) SetSocketOption(SocketOptionLevel, SocketOptionName, Boolean) SetSocketOption(SocketOptionLevel, SocketOptionName, Boolean)

Define a opção Socket especificada para o valor especificado de Boolean.Sets the specified Socket option to the specified Boolean value.

SetSocketOption(SocketOptionLevel, SocketOptionName, Byte[]) SetSocketOption(SocketOptionLevel, SocketOptionName, Byte[]) SetSocketOption(SocketOptionLevel, SocketOptionName, Byte[]) SetSocketOption(SocketOptionLevel, SocketOptionName, Byte[])

Define a opção Socket especificada para o valor especificado, representado como uma matriz de bytes.Sets the specified Socket option to the specified value, represented as a byte array.

SetSocketOption(SocketOptionLevel, SocketOptionName, Int32) SetSocketOption(SocketOptionLevel, SocketOptionName, Int32) SetSocketOption(SocketOptionLevel, SocketOptionName, Int32) SetSocketOption(SocketOptionLevel, SocketOptionName, Int32)

Define a opção Socket especificada para o valor inteiro especificado.Sets the specified Socket option to the specified integer value.

SetSocketOption(SocketOptionLevel, SocketOptionName, Object) SetSocketOption(SocketOptionLevel, SocketOptionName, Object) SetSocketOption(SocketOptionLevel, SocketOptionName, Object) SetSocketOption(SocketOptionLevel, SocketOptionName, Object)

Define a opção Socket especificada com o valor especificado, representado como um objeto.Sets the specified Socket option to the specified value, represented as an object.

Shutdown(SocketShutdown) Shutdown(SocketShutdown) Shutdown(SocketShutdown) Shutdown(SocketShutdown)

Desabilita envios e recebimentos em um Socket.Disables sends and receives on a Socket.

ToString() ToString() ToString() ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Inherited from Object)

Implantações explícitas de interface

IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose()

Libera todos os recursos usados pelo Socket.Releases all resources used by the Socket.

Métodos de Extensão

AcceptAsync(Socket) AcceptAsync(Socket) AcceptAsync(Socket) AcceptAsync(Socket)

Executa uma operação assíncrona para aceitar uma tentativa de conexão de entrada no soquete.Performs an asynchronous operation on to accept an incoming connection attempt on the socket.

AcceptAsync(Socket, Socket) AcceptAsync(Socket, Socket) AcceptAsync(Socket, Socket) AcceptAsync(Socket, Socket)

Executa uma operação assíncrona para aceitar uma tentativa de conexão de entrada no soquete.Performs an asynchronous operation on to accept an incoming connection attempt on the socket.

ConnectAsync(Socket, EndPoint) ConnectAsync(Socket, EndPoint) ConnectAsync(Socket, EndPoint) ConnectAsync(Socket, EndPoint)

Estabelece uma conexão com o host remoto.Establishes a connection to a remote host.

ConnectAsync(Socket, IPAddress, Int32) ConnectAsync(Socket, IPAddress, Int32) ConnectAsync(Socket, IPAddress, Int32) ConnectAsync(Socket, IPAddress, Int32)

Estabelece uma conexão com o host remoto.Establishes a connection to a remote host. O host é especificado por um endereço IP e um número da porta.The host is specified by an IP address and a port number.

ConnectAsync(Socket, IPAddress[], Int32) ConnectAsync(Socket, IPAddress[], Int32) ConnectAsync(Socket, IPAddress[], Int32) ConnectAsync(Socket, IPAddress[], Int32)

Estabelece uma conexão com o host remoto.Establishes a connection to a remote host. O host é especificado por uma matriz de endereços IP e um número da porta.The host is specified by an array of IP addresses and a port number.

ConnectAsync(Socket, String, Int32) ConnectAsync(Socket, String, Int32) ConnectAsync(Socket, String, Int32) ConnectAsync(Socket, String, Int32)

Estabelece uma conexão com o host remoto.Establishes a connection to a remote host. O host é especificado por um nome do host e um número da porta.The host is specified by a host name and a port number.

ReceiveAsync(Socket, ArraySegment<Byte>, SocketFlags) ReceiveAsync(Socket, ArraySegment<Byte>, SocketFlags) ReceiveAsync(Socket, ArraySegment<Byte>, SocketFlags) ReceiveAsync(Socket, ArraySegment<Byte>, SocketFlags)

Recebe os dados de um soquete conectado.Receives data from a connected socket.

ReceiveAsync(Socket, IList<ArraySegment<Byte>>, SocketFlags) ReceiveAsync(Socket, IList<ArraySegment<Byte>>, SocketFlags) ReceiveAsync(Socket, IList<ArraySegment<Byte>>, SocketFlags) ReceiveAsync(Socket, IList<ArraySegment<Byte>>, SocketFlags)

Recebe os dados de um soquete conectado.Receives data from a connected socket.

ReceiveAsync(Socket, Memory<Byte>, SocketFlags, CancellationToken) ReceiveAsync(Socket, Memory<Byte>, SocketFlags, CancellationToken) ReceiveAsync(Socket, Memory<Byte>, SocketFlags, CancellationToken) ReceiveAsync(Socket, Memory<Byte>, SocketFlags, CancellationToken)
ReceiveFromAsync(Socket, ArraySegment<Byte>, SocketFlags, EndPoint) ReceiveFromAsync(Socket, ArraySegment<Byte>, SocketFlags, EndPoint) ReceiveFromAsync(Socket, ArraySegment<Byte>, SocketFlags, EndPoint) ReceiveFromAsync(Socket, ArraySegment<Byte>, SocketFlags, EndPoint)

Recebe dados de um dispositivo de rede especificado.Receives data from a specified network device.

ReceiveMessageFromAsync(Socket, ArraySegment<Byte>, SocketFlags, EndPoint) ReceiveMessageFromAsync(Socket, ArraySegment<Byte>, SocketFlags, EndPoint) ReceiveMessageFromAsync(Socket, ArraySegment<Byte>, SocketFlags, EndPoint) ReceiveMessageFromAsync(Socket, ArraySegment<Byte>, SocketFlags, EndPoint)

Recebe o número de bytes de dados no local especificado no buffer de dados usando o SocketFlags especificado e armazena as informações de ponto de extremidade e pacote.Receives the specified number of bytes of data into the specified location of the data buffer, using the specified SocketFlags, and stores the endpoint and packet information.

SendAsync(Socket, ArraySegment<Byte>, SocketFlags) SendAsync(Socket, ArraySegment<Byte>, SocketFlags) SendAsync(Socket, ArraySegment<Byte>, SocketFlags) SendAsync(Socket, ArraySegment<Byte>, SocketFlags)

Envia dados para um soquete conectado.Sends data to a connected socket.

SendAsync(Socket, IList<ArraySegment<Byte>>, SocketFlags) SendAsync(Socket, IList<ArraySegment<Byte>>, SocketFlags) SendAsync(Socket, IList<ArraySegment<Byte>>, SocketFlags) SendAsync(Socket, IList<ArraySegment<Byte>>, SocketFlags)

Envia dados para um soquete conectado.Sends data to a connected socket.

SendAsync(Socket, ReadOnlyMemory<Byte>, SocketFlags, CancellationToken) SendAsync(Socket, ReadOnlyMemory<Byte>, SocketFlags, CancellationToken) SendAsync(Socket, ReadOnlyMemory<Byte>, SocketFlags, CancellationToken) SendAsync(Socket, ReadOnlyMemory<Byte>, SocketFlags, CancellationToken)
SendToAsync(Socket, ArraySegment<Byte>, SocketFlags, EndPoint) SendToAsync(Socket, ArraySegment<Byte>, SocketFlags, EndPoint) SendToAsync(Socket, ArraySegment<Byte>, SocketFlags, EndPoint) SendToAsync(Socket, ArraySegment<Byte>, SocketFlags, EndPoint)

Envia dados de maneira assíncrona para um host remoto específico.Sends data asynchronously to a specific remote host.

Segurança

SocketPermission
Para estabelecer uma conexão de saída ou aceitar uma solicitação de entrada.To establish an outgoing connection or accept an incoming request.

Aplica-se a

Acesso thread-safe

As instâncias dessa classe são thread-safe.Instances of this class are thread safe.

Veja também