SocketAddress 클래스

정의

EndPoint 파생 클래스의 serialize된 정보를 저장합니다.

public ref class SocketAddress
public ref class SocketAddress : IEquatable<System::Net::SocketAddress ^>
public class SocketAddress
public class SocketAddress : IEquatable<System.Net.SocketAddress>
type SocketAddress = class
type SocketAddress = class
    interface IEquatable<SocketAddress>
Public Class SocketAddress
Public Class SocketAddress
Implements IEquatable(Of SocketAddress)
상속
SocketAddress
구현

예제

다음 예제에서는 를 사용하여 SocketAddress 클래스의 instance 직렬화하는 방법을 보여 줍니다EndPoint. serialization 후 의 SocketAddress 기본 바이트 버퍼에는 모든 IPEndPoint 상태 정보가 포함됩니다.

//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 대해 예약됩니다. SocketAddress 가 직렬화된 IPEndPoint를 저장하는 데 사용되는 경우 세 번째 및 네 번째 바이트는 포트 번호 정보를 저장하는 데 사용됩니다. 다음 바이트는 IP 주소를 저장하는 데 사용됩니다. 인덱스 위치를 참조하여 이 기본 바이트 버퍼 내의 모든 정보에 액세스할 수 있습니다. 바이트 버퍼는 0부터 시작하는 인덱싱을 사용합니다. 및 속성을 사용하여 Family 각각 값과 버퍼 크기를 가져올 AddressFamily 수도 Size 있습니다. 이 정보를 문자열로 보려면 메서드를 ToString 사용합니다.

생성자

SocketAddress(AddressFamily)

지정된 주소 패밀리에 대한 SocketAddress 클래스의 새 인스턴스를 만듭니다.

SocketAddress(AddressFamily, Int32)

지정된 주소 패밀리와 버퍼 크기를 사용하여 SocketAddress 클래스의 새 인스턴스를 만듭니다.

속성

Buffer

네이티브 OS 호출에 전달할 수 있는 기본 메모리를 가져옵니다.

Family

현재 AddressFamilySocketAddress 열거형 값을 가져옵니다.

Item[Int32]

내부 버퍼의 지정된 인덱스 요소를 가져오거나 설정합니다.

Size

SocketAddress의 내부 버퍼 크기를 가져옵니다.

메서드

Equals(Object)

지정한 Object가 현재 Object와 같은지 여부를 확인합니다.

Equals(SocketAddress)

현재 개체가 동일한 형식의 다른 개체와 같은지 여부를 나타냅니다.

GetHashCode()

특정 유형에 대한 해시 함수의 역할을 하며, 해시 알고리즘 및 해시 테이블과 같은 데이터 구조에 사용할 수 있습니다.

GetMaximumAddressSize(AddressFamily)

지정된 AddressFamily에 필요한 최대 버퍼 크기를 가져옵니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

소켓 주소에 대한 정보를 반환합니다.

적용 대상