Socket Socket Socket Socket Class

Definición

Implementa la interfaz de sockets 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
Herencia
SocketSocketSocketSocket
Implementaciones

Ejemplos

En el ejemplo de código siguiente se Socket muestra cómo se puede utilizar la clase para enviar datos a un servidor http y recibir la respuesta.The following code example shows how the Socket class can be used to send data to an HTTP server and receive the response. Este ejemplo se bloquea hasta que se recibe toda la página.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.Text
Imports System.IO
Imports System.Net
Imports System.Net.Sockets

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  

Comentarios

La Socket clase proporciona un amplio conjunto de métodos y propiedades para las comunicaciones de red.The Socket class provides a rich set of methods and properties for network communications. La Socket clase le permite realizar transferencias de datos sincrónicas y asincrónicas utilizando cualquiera de los protocolos de comunicación que ProtocolType se enumeran en la enumeración.The Socket class allows you to perform both synchronous and asynchronous data transfer using any of the communication protocols listed in the ProtocolType enumeration.

La Socket clase sigue el .NET Framework patrón de nomenclatura para los métodos asincrónicos.The Socket class follows the .NET Framework naming pattern for asynchronous methods. Por ejemplo, el Receive método sincrónico se corresponde con los métodos BeginReceive asincrónicos EndReceive y.For example, the synchronous Receive method corresponds to the asynchronous BeginReceive and EndReceive methods.

Si la aplicación solo necesita un subproceso durante la ejecución, use los métodos siguientes, que están diseñados para el modo de funcionamiento sincrónico.If your application only requires one thread during execution, use the following methods, which are designed for synchronous operation mode.

  • Si utiliza un protocolo orientado a la conexión, como TCP, el servidor puede escuchar las conexiones mediante el Listen método.If you are using a connection-oriented protocol such as TCP, your server can listen for connections using the Listen method. El Accept método procesa cualquier solicitud de conexión entrante y devuelve Socket un que se puede utilizar para comunicar datos con el 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 este devuelto Socket para Send llamar al Receive método o.Use this returned Socket to call the Send or Receive method. Llame al Bind método antes de llamar al Listen método si desea especificar la dirección IP local y el número de puerto.Call the Bind method prior to calling the Listen method if you want to specify the local IP address and port number. Use un número de puerto de cero si desea que el proveedor de servicios subyacente asigne un puerto gratuito.Use a port number of zero if you want the underlying service provider to assign a free port for you. Si desea conectarse a un host de escucha, llame Connect al método.If you want to connect to a listening host, call the Connect method. Para comunicar datos, llame al Send método Receive o.To communicate data, call the Send or Receive method.

  • Si utiliza un protocolo sin conexión como UDP, no es necesario que escuche las conexiones en absoluto.If you are using a connectionless protocol such as UDP, you do not need to listen for connections at all. Llame al ReceiveFrom método para aceptar los datagramas entrantes.Call the ReceiveFrom method to accept any incoming datagrams. Use el SendTo método para enviar datagramas a un host remoto.Use the SendTo method to send datagrams to a remote host.

Para procesar las comunicaciones con subprocesos independientes durante la ejecución, use los métodos siguientes, que están diseñados para el modo de operación asincrónica.To process communications using separate threads during execution, use the following methods, which are designed for asynchronous operation mode.

Si realiza varias operaciones asincrónicas en un socket, no se completan necesariamente en el orden en que se inician.If you perform multiple asynchronous operations on a socket, they do not necessarily complete in the order in which they are started.

Cuando haya terminado de enviar y recibir datos, utilice el Shutdown método para Socketdeshabilitar.When you are finished sending and receiving data, use the Shutdown method to disable the Socket. Después de Shutdownllamar a, Close llame al método para liberar Sockettodos los recursos asociados a.After calling Shutdown, call the Close method to release all resources associated with the Socket.

La Socket clase le permite Socket configurar el mediante el SetSocketOption método.The Socket class allows you to configure your Socket using the SetSocketOption method. Recupere estos valores mediante GetSocketOption el método.Retrieve these settings using the GetSocketOption method.

Nota

Si está escribiendo una aplicación relativamente sencilla y no requiere un rendimiento máximo, considere la posibilidad TcpClientde TcpListenerusar, UdpClienty.If you are writing a relatively simple application and do not require maximum performance, consider using TcpClient, TcpListener, and UdpClient. Estas clases proporcionan una interfaz más sencilla y fácil de ver con Socket las comunicaciones.These classes provide a simpler and more user-friendly interface to Socket communications.

Constructores

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

Inicializa una instancia nueva de la clase Socket con la familia de direcciones, el tipo de socket y el protocolo que se especifiquen.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 una nueva instancia de la clase Socket utilizando el valor devuelto por 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 una instancia nueva de la clase Socket usando el tipo de socket y el protocolo que se especifiquen.Initializes a new instance of the Socket class using the specified socket type and protocol.

Propiedades

AddressFamily AddressFamily AddressFamily AddressFamily

Obtiene la familia de direcciones de Socket.Gets the address family of the Socket.

Available Available Available Available

Obtiene la cantidad de datos que se han recibido de la red y están disponibles para leer.Gets the amount of data that has been received from the network and is available to be read.

Blocking Blocking Blocking Blocking

Obtiene o establece un valor que indica si Socket está en modo de bloqueo.Gets or sets a value that indicates whether the Socket is in blocking mode.

Connected Connected Connected Connected

Obtiene un valor que indica si Socket se conecta con un host remoto a partir de la última operación Send u 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

Obtiene o establece un valor de Boolean que especifica si Socket permite fragmentar los datagramas de protocolo Internet (IP).Gets or sets a Boolean value that specifies whether the Socket allows Internet Protocol (IP) datagrams to be fragmented.

DualMode DualMode DualMode DualMode

Obtiene o establece un valor Boolean que especifica si Socket es un socket de modo dual que se usa tanto para IPv4 como para 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

Obtiene o establece un valor de Boolean que especifica si Socket puede enviar o recibir paquetes de difusión.Gets or sets a Boolean value that specifies whether the Socket can send or receive broadcast packets.

ExclusiveAddressUse ExclusiveAddressUse ExclusiveAddressUse ExclusiveAddressUse

Obtiene o establece un valor de Boolean que especifica si Socket permite sólo a un proceso el enlace a un puerto.Gets or sets a Boolean value that specifies whether the Socket allows only one process to bind to a port.

Handle Handle Handle Handle

Obtiene el identificador del sistema operativo de Socket.Gets the operating system handle for the Socket.

IsBound IsBound IsBound IsBound

Obtiene un valor que indica si Socket se enlaza a un puerto local concreto.Gets a value that indicates whether the Socket is bound to a specific local port.

LingerState LingerState LingerState LingerState

Obtiene o establece un valor que especifica si Socket retrasará el cierre de un socket en un intento de envío de todos los datos pendientes.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

Obtiene el extremo local.Gets the local endpoint.

MulticastLoopback MulticastLoopback MulticastLoopback MulticastLoopback

Obtiene o establece un valor que especifica si se entregan paquetes de multidifusión saliente a la aplicación emisora.Gets or sets a value that specifies whether outgoing multicast packets are delivered to the sending application.

NoDelay NoDelay NoDelay NoDelay

Obtiene o establece un valor de Boolean que especifica si la secuencia Socket está utilizando el 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 si el sistema operativo subyacente y los adaptadores de red admiten la versión 4 del protocolo de Internet (IPv4).Indicates whether the underlying operating system and network adaptors support Internet Protocol version 4 (IPv4).

OSSupportsIPv6 OSSupportsIPv6 OSSupportsIPv6 OSSupportsIPv6

Indica si el sistema operativo subyacente y los adaptadores de red admiten la versión 6 del protocolo Internet (IPv6).Indicates whether the underlying operating system and network adaptors support Internet Protocol version 6 (IPv6).

ProtocolType ProtocolType ProtocolType ProtocolType

Obtiene el tipo de protocolo de Socket.Gets the protocol type of the Socket.

ReceiveBufferSize ReceiveBufferSize ReceiveBufferSize ReceiveBufferSize

Obtiene o establece un valor que especifica el tamaño del búfer de recepción de Socket.Gets or sets a value that specifies the size of the receive buffer of the Socket.

ReceiveTimeout ReceiveTimeout ReceiveTimeout ReceiveTimeout

Obtiene o establece un valor que especifica el tiempo tras el que una llamada Receive sincrónica pasará a tiempo de espera.Gets or sets a value that specifies the amount of time after which a synchronous Receive call will time out.

RemoteEndPoint RemoteEndPoint RemoteEndPoint RemoteEndPoint

Obtiene el extremo remoto.Gets the remote endpoint.

SafeHandle SafeHandle SafeHandle SafeHandle

Obtiene un elemento SafeSocketHandle que representa el identificador de socket que encapsula el objeto Socket actual.Gets a SafeSocketHandle that represents the socket handle that the current Socket object encapsulates.

SendBufferSize SendBufferSize SendBufferSize SendBufferSize

Obtiene o establece un valor que especifica el tamaño del búfer de envío de Socket.Gets or sets a value that specifies the size of the send buffer of the Socket.

SendTimeout SendTimeout SendTimeout SendTimeout

Obtiene o establece un valor que especifica el tiempo tras el que una llamada Send sincrónica pasará a tiempo de espera.Gets or sets a value that specifies the amount of time after which a synchronous Send call will time out.

SocketType SocketType SocketType SocketType

Obtiene el tipo de Socket.Gets the type of the Socket.

SupportsIPv4 SupportsIPv4 SupportsIPv4 SupportsIPv4

Obtiene un valor que indica si la compatibilidad con IPv4 está disponible y habilitada en el host actual.Gets a value indicating whether IPv4 support is available and enabled on the current host.

SupportsIPv6 SupportsIPv6 SupportsIPv6 SupportsIPv6

Obtiene un valor que indica si el marco de trabajo admite IPv6 para ciertos miembros Dns obsoletos.Gets a value that indicates whether the Framework supports IPv6 for certain obsolete Dns members.

Ttl Ttl Ttl Ttl

Obtiene o establece un valor que especifica el valor de período de vida (TTL) de los paquetes de protocolo Internet (IP) enviados por 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 si el socket debe utilizar únicamente el modo de E/S superpuesta.Specifies whether the socket should only use Overlapped I/O mode.

Métodos

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

Crea un nuevo objeto Socket para una conexión recién establecida.Creates a new Socket for a newly created connection.

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

Comienza una operación asincrónica para aceptar un intento de conexión entrante.Begins an asynchronous operation to accept an incoming connection attempt.

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

Comienza una operación asincrónica para aceptar un intento de conexión entrante.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)

Comienza una operación asincrónica para aceptar un intento de conexión entrante y recibe el primer bloque de datos enviado por la aplicación 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)

Comienza una operación asincrónica para aceptar un intento de conexión entrante desde un socket específico y recibe el primer bloque de datos enviado por la aplicación 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 una solicitud asincrónica para una conexión a 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 una solicitud asincrónica para una conexión a host remoto.Begins an asynchronous request for a remote host connection. El host se especifica mediante una IPAddress y un número de puerto.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 una solicitud asincrónica para una conexión a host remoto.Begins an asynchronous request for a remote host connection. El host se especifica mediante una matriz IPAddress y un número de puerto.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 una solicitud asincrónica para una conexión a host remoto.Begins an asynchronous request for a remote host connection. El host se especifica mediante un nombre de host y un número de puerto.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)

Comienza una solicitud asincrónica para la desconexión de un extremo 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)

Comienza a recibir asincrónicamente los datos de un objeto 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)

Comienza a recibir asincrónicamente los datos de un objeto 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)

Comienza a recibir asincrónicamente los datos de un objeto 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)

Comienza a recibir asincrónicamente los datos de un objeto 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)

Comienza a recibir asincrónicamente los datos de un dispositivo de red especificado.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)

Empieza a recibir de forma asincrónica el número especificado de bytes de datos en la ubicación indicada del búfer de datos, mediante el marcador SocketFlags especificado, y almacena el punto de conexión y la información sobre paquetes.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)

Envía datos asincrónicamente a un objeto 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)

Envía datos asincrónicamente a un objeto 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)

Envía datos asincrónicamente a un objeto 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)

Envía datos asincrónicamente a un objeto 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)

Envía el archivo fileName a un objeto Socket conectado mediante el marcador 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)

Envía, de forma asincrónica, un archivo y búferes de datos a un 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)

Envía datos de forma asincrónica a un host remoto concreto.Sends data asynchronously to a specific remote host.

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

Asocia un objeto Socket a un extremo local.Associates a Socket with a local endpoint.

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

Cancela una solicitud asincrónica de una conexión a un host remoto.Cancels an asynchronous request for a remote host connection.

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

Cierra la conexión Socket y libera todos los recursos asociados.Closes the Socket connection and releases all associated resources.

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

Cierra la conexión Socket y libera todos los recursos asociados con un tiempo de espera especificado para permitir el envío de los datos en cola.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)

Establece una conexión a un host remoto.Establishes a connection to a remote host.

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

Establece una conexión a un host remoto.Establishes a connection to a remote host. El host se especifica mediante una dirección IP y un número de puerto.The host is specified by an IP address and a port number.

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

Establece una conexión a un host remoto.Establishes a connection to a remote host. El host se especifica mediante una matriz de direcciones IP y un número de puerto.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)

Establece una conexión a un host remoto.Establishes a connection to a remote host. El host se especifica mediante un nombre de host y un número de puerto.The host is specified by a host name and a port number.

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

Comienza una solicitud asincrónica para una conexión a 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)

Comienza una solicitud asincrónica para una conexión a host remoto.Begins an asynchronous request for a connection to a remote host.

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

Cierra la conexión del socket y permite reutilizarlo.Closes the socket connection and allows reuse of the socket.

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

Comienza una solicitud asincrónica para la desconexión de un extremo remoto.Begins an asynchronous request to disconnect from a remote endpoint.

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

Libera todos los recursos usados por la instancia actual de la clase Socket.Releases all resources used by the current instance of the Socket class.

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

Libera los recursos no administrados que usa Socket y, de forma opcional, desecha los recursos administrados.Releases the unmanaged resources used by the Socket, and optionally disposes of the managed resources.

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

Duplica la referencia del socket para el proceso de destino y cierra el socket para este proceso.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)

Acepta de forma asincrónica un intento de conexión entrante y crea un objeto Socket nuevo para controlar la comunicación con el host remoto.Asynchronously accepts an incoming connection attempt and creates a new Socket object to handle remote host communication. Este método devuelve un búfer que contiene los datos iniciales 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)

Acepta de forma asincrónica un intento de conexión entrante y crea un objeto Socket nuevo para controlar la comunicación con el host remoto.Asynchronously accepts an incoming connection attempt and creates a new Socket object to handle remote host communication. Este método devuelve un búfer que contiene los datos iniciales y el 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)

Acepta asincrónicamente un intento de conexión entrante y crea un nuevo objeto Socket para controlar la comunicación con el 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)

Finaliza una solicitud de conexión asincrónica pendiente.Ends a pending asynchronous connection request.

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

Finaliza una solicitud de desconexión asincrónica pendiente.Ends a pending asynchronous disconnect request.

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

Finaliza una lectura asincrónica pendiente.Ends a pending asynchronous read.

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

Finaliza una lectura asincrónica pendiente.Ends a pending asynchronous read.

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

Finaliza una lectura asincrónica pendiente desde un extremo 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)

Finaliza una lectura asincrónica pendiente desde un extremo específico.Ends a pending asynchronous read from a specific endpoint. Este método también desvela más información sobre el paquete 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)

Finaliza un envío asincrónico pendiente.Ends a pending asynchronous send.

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

Finaliza un envío asincrónico pendiente.Ends a pending asynchronous send.

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

Finaliza un envío asincrónico de archivo pendiente.Ends a pending asynchronous send of a file.

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

Finaliza un envío asincrónico pendiente en una ubicación específica.Ends a pending asynchronous send to a specific location.

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

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

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

Libera los recursos utilizados por la clase Socket.Frees resources used by the Socket class.

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

Devuelve un valor hash para una instancia de Socket.Returns a hash value for a Socket instance.

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

Devuelve el valor de una opción de Socket especificada en forma de 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[])

Devuelve el valor de la opción de Socket especificada, representado como una 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)

Devuelve el valor de la opción de Socket especificada en una matriz.Returns the value of the specified Socket option in an array.

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

Obtiene el Type de la instancia actual.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[])

Establece modos operativos de bajo nivel para el Socket que utiliza códigos de control 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[])

Establece modos operativos de bajo nivel para el Socket que utiliza la enumeración IOControlCode para especificar códigos de control.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 un objeto Socket en un estado de escucha.Places a Socket in a listening state.

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

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

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

Determina el estado de Socket.Determines the status of the Socket.

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

Recibe datos de un Socket enlazado en un búfer de recepción.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)

Recibe el número especificado de bytes de un objeto Socket enlazado en la posición de desplazamiento especificada del búfer de recepción, usando el valor de 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)

Recibe datos de un Socket enlazado en un búfer de recepción, usando el valor de 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)

Recibe el número especificado de bytes de datos de un objeto Socket enlazado en un búfer de recepción, usando el valor de 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)

Recibe datos de un Socket enlazado en un búfer de recepción, usando el valor de 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>>)

Recibe, en la lista de búferes de recepción, datos de un Socket enlazado.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)

Recibe, en la lista de búferes de recepción, datos de un Socket enlazado, utilizando el valor de 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)

Recibe, en la lista de búferes de recepción, datos de un Socket enlazado, utilizando el valor de 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)

Comienza una solicitud asincrónica para recibir los datos de un 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)

Recibe un datagrama en el búfer de datos y almacena el extremo.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)

Recibe el número especificado de bytes de datos en la ubicación especificada del búfer de datos, mediante el SocketFlags especificado y almacena el punto de conexión.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)

Recibe el número especificado de bytes en el búfer de datos mediante el marcador SocketFlags especificado y almacena el extremo.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)

Recibe un datagrama en el búfer de datos usando el objeto SocketFlags especificado y almacena el extremo.Receives a datagram into the data buffer, using the specified SocketFlags, and stores the endpoint.

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

Comienza a recibir asincrónicamente los datos de un dispositivo de red especificado.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)

Recibe el número especificado de bytes de datos en la ubicación especificada del búfer de datos, mediante el elemento SocketFlags especificado y almacena el punto de conexión y la información del paquete.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)

Comienza a recibir de forma asincrónica el número especificado de bytes de datos en la ubicación indicada del búfer de datos, mediante la propiedad SocketFlags especificada, y almacena la información sobre el extremo y el paquete.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 el estado de uno o varios sockets.Determines the status of one or more sockets.

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

Envía datos a un objeto 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)

Envía el número especificado de bytes de datos a un Socket conectado, comenzando en el desplazamiento especificado y usando el SocketFlags especificado.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)

Envía el número especificado de bytes de datos a un objeto Socket conectado, a partir de la posición de desplazamiento especificada y usando el valor de SocketFlags especificado.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, SocketFlags) Send(Byte[], Int32, SocketFlags) Send(Byte[], Int32, SocketFlags) Send(Byte[], Int32, SocketFlags)

Envía el número especificado de bytes de datos a un objeto Socket conectado, usando el marcador 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)

Envía datos a un objeto Socket conectado mediante el marcador 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>>)

Envía el conjunto de búferes de la lista a un 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)

Envía el conjunto de búferes de la lista a un Socket conectado, utilizando el 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)

Envía el conjunto de búferes de la lista a un Socket conectado, utilizando el 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)

Envía datos de forma asincrónica a un objeto Socket conectado.Sends data asynchronously to a connected Socket object.

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

Envía el archivo fileName a un objeto Socket conectado con el marcador de transmisión 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)

Envía el archivo fileName y búferes de datos a un objeto Socket conectado mediante el 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)

Envía de forma asincrónica una colección de archivos o búferes de datos en memoria a un 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)

Envía los datos al extremo 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)

Envía el número especificado de bytes de datos al extremo especificado, comenzando en la ubicación especificada del búfer y usando los SocketFlags especificados.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)

Envía el número especificado de bytes de datos al extremo especificado usando los SocketFlags especificados.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)

Envía datos a un extremo específico mediante el marcador SocketFlags especificado.Sends data to a specific endpoint using the specified SocketFlags.

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

Envía datos de forma asincrónica a un host remoto concreto.Sends data asynchronously to a specific remote host.

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

Establece el nivel de protección IP en un socket.Set the IP protection level on a socket.

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

Establece la opción de Socket especificada en el valor de Boolean indicado.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[])

Establece la opción de Socket indicada en el valor especificado, representado como una 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)

Establece la opción de Socket especificada en el valor entero indicado.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)

Establece la opción de Socket indicada en el valor especificado, representado como un objeto.Sets the specified Socket option to the specified value, represented as an object.

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

Deshabilita los envíos y recepciones en un objeto Socket.Disables sends and receives on a Socket.

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

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Implementaciones de interfaz explícitas

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

Libera todos los recursos que usa Socket.Releases all resources used by the Socket.

Métodos de extensión

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

Realiza una operación asincrónica para aceptar un intento de conexión entrante en el socket.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)

Realiza una operación asincrónica para aceptar un intento de conexión entrante en el socket.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)

Establece una conexión a un 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)

Establece una conexión a un host remoto.Establishes a connection to a remote host. El host se especifica mediante una dirección IP y un número de puerto.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)

Establece una conexión a un host remoto.Establishes a connection to a remote host. El host se especifica mediante una matriz de direcciones IP y un número de puerto.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)

Establece una conexión a un host remoto.Establishes a connection to a remote host. El host se especifica mediante un nombre de host y un número de puerto.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)

Recibe datos de un socket 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)

Recibe datos de un socket 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)

Recibe datos de un dispositivo de red 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)

Recibe el número especificado de bytes de datos en la ubicación especificada del búfer de datos, mediante el elemento SocketFlags especificado y almacena el punto de conexión y la información del paquete.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)

Envía datos a un socket 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)

Envía datos a un socket 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)

Envía datos de forma asincrónica a un host remoto concreto.Sends data asynchronously to a specific remote host.

Seguridad

SocketPermission
Para establecer una conexión de salida o aceptar una solicitud entrante.To establish an outgoing connection or accept an incoming request.

Se aplica a

Seguridad para subprocesos

Las instancias de esta clase son seguras para subprocesos.Instances of this class are thread safe.

Consulte también: