SocketAddress SocketAddress SocketAddress SocketAddress Class

정의

EndPoint 파생 클래스의 serialize된 정보를 저장합니다.Stores serialized information from EndPoint derived classes.

public ref class SocketAddress
public class SocketAddress
type SocketAddress = class
Public Class SocketAddress
상속
SocketAddressSocketAddressSocketAddressSocketAddress

예제

다음 예제에서는 사용 하는 방법을 보여 줍니다 SocketAddress 의 인스턴스를 serialize 하는 EndPoint 클래스입니다.The following example demonstrates how to use SocketAddress to serialize an instance of the EndPoint class. 이후에 기본 바이트 버퍼를 SocketAddress 모두 포함 합니다 IPEndPoint 상태 정보.After serialization, the underlying byte buffer of the SocketAddress contains all of the IPEndPoint state information.

//Creates an IpEndPoint.
IPAddress^ ipAddress = Dns::Resolve( "www.contoso.com" )->AddressList[ 0 ];
IPEndPoint^ ipLocalEndPoint = gcnew IPEndPoint( ipAddress,11000 );

//Serializes the IPEndPoint.
SocketAddress^ socketAddress = ipLocalEndPoint->Serialize();

//Verifies that ipLocalEndPoint is now serialized by printing its contents.
Console::WriteLine( "Contents of the socketAddress are: {0}", socketAddress );
//Checks the Family property.
Console::WriteLine( "The address family of the socketAddress is: {0}", socketAddress->Family );
//Checks the underlying buffer size.
Console::WriteLine( "The size of the underlying buffer is: {0}", socketAddress->Size );

//Creates an IpEndPoint.
IPAddress ipAddress = Dns.Resolve("www.contoso.com").AddressList[0];
IPEndPoint ipLocalEndPoint = new IPEndPoint(ipAddress, 11000);

//Serializes the IPEndPoint. 
SocketAddress socketAddress = ipLocalEndPoint.Serialize();

//Verifies that ipLocalEndPoint is now serialized by printing its contents.
Console.WriteLine("Contents of the socketAddress are: " + socketAddress.ToString());
//Checks the Family property.
Console.WriteLine("The address family of the socketAddress is: " + socketAddress.Family.ToString());
//Checks the underlying buffer size.
Console.WriteLine("The size of the underlying buffer is: " + socketAddress.Size.ToString());

   'Creates an IpEndPoint.
   Dim ipAddress As IPAddress = Dns.Resolve("www.contoso.com").AddressList(0)
   Dim ipLocalEndPoint As New IPEndPoint(ipAddress, 11000)
   
   'Serializes the IPEndPoint. 
   Dim socketAddress As SocketAddress = ipLocalEndPoint.Serialize()
   
   'Verifies that ipLocalEndPoint is now serialized by printing its contents.
   Console.WriteLine(("Contents of socketAddress are: " + socketAddress.ToString()))
   'Checks the Family property.
   Console.WriteLine(("The address family of socketAddress is: " + socketAddress.Family.ToString()))
   'Checks the underlying buffer size.
   Console.WriteLine(("The size of the underlying buffer is: " + socketAddress.Size.ToString()))
End Sub
 

설명

내부 버퍼의 처음 2 바이트에 대 한 예약 되어 있으므로 AddressFamily 열거형 값입니다.The first 2 bytes of the underlying buffer are reserved for the AddressFamily enumerated value. 경우는 SocketAddress 는 직렬화 된 IPEndPoint, 세 번째 및 네 번째 바이트를 사용 하 여 포트 번호 정보를 저장 합니다.When the SocketAddress is used to store a serialized IPEndPoint, the third and fourth bytes are used to store port number information. 다음 바이트는 IP 주소를 저장 하는 데 사용 됩니다.The next bytes are used to store the IP address. 해당 인덱스 위치를 참조 하 여이 기본 바이트 버퍼 내에서 모든 정보에 액세스할 수 있습니다. 인덱스가 0부터 시작 바이트 버퍼를 사용합니다.You can access any information within this underlying byte buffer by referring to its index position; the byte buffer uses zero-based indexing. 사용할 수도 있습니다는 Family 하 고 Size 속성을는 AddressFamily 값 및 버퍼 크기를 각각.You can also use the Family and Size properties to get the AddressFamily value and the buffer size, respectively. 문자열로이 정보를 보려면 사용 하 여를 ToString 메서드.To view any of this information as a string, use the ToString method.

생성자

SocketAddress(AddressFamily) SocketAddress(AddressFamily) SocketAddress(AddressFamily) SocketAddress(AddressFamily)

지정된 주소 패밀리에 대한 SocketAddress 클래스의 새 인스턴스를 만듭니다.Creates a new instance of the SocketAddress class for the given address family.

SocketAddress(AddressFamily, Int32) SocketAddress(AddressFamily, Int32) SocketAddress(AddressFamily, Int32) SocketAddress(AddressFamily, Int32)

지정된 주소 패밀리와 버퍼 크기를 사용하여 SocketAddress 클래스의 새 인스턴스를 만듭니다.Creates a new instance of the SocketAddress class using the specified address family and buffer size.

속성

Family Family Family Family

현재 AddressFamilySocketAddress 열거형 값을 가져옵니다.Gets the AddressFamily enumerated value of the current SocketAddress.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

내부 버퍼의 지정된 인덱스 요소를 가져오거나 설정합니다.Gets or sets the specified index element in the underlying buffer.

Size Size Size Size

SocketAddress의 내부 버퍼 크기를 가져옵니다.Gets the underlying buffer size of the SocketAddress.

메서드

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

지정한 Object가 현재 Object와 같은지 여부를 확인합니다.Determines whether the specified Object is equal to the current Object.

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

특정 형식에 대한 해시 함수로 사용되며, 해시 알고리즘 및 해시 테이블과 같은 데이터 구조에 사용하기 적합합니다.Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.

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

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

소켓 주소에 대한 정보를 반환합니다.Returns information about the socket address.

적용 대상