영어로 읽기

다음을 통해 공유


IPEndPoint 생성자

정의

IPEndPoint 클래스의 새 인스턴스를 초기화합니다.

오버로드

IPEndPoint(Int64, Int32)

지정된 주소와 포트 번호를 사용하여 IPEndPoint 클래스의 새 인스턴스를 초기화합니다.

IPEndPoint(IPAddress, Int32)

지정된 주소와 포트 번호를 사용하여 IPEndPoint 클래스의 새 인스턴스를 초기화합니다.

IPEndPoint(Int64, Int32)

Source:
IPEndPoint.cs
Source:
IPEndPoint.cs
Source:
IPEndPoint.cs

지정된 주소와 포트 번호를 사용하여 IPEndPoint 클래스의 새 인스턴스를 초기화합니다.

C#
public IPEndPoint (long address, int port);

매개 변수

address
Int64

인터넷 호스트의 IP 주소입니다. 예를 들어, big-endian 형식의 0x2414188f 값은 IP 주소가 "143.24.20.36"입니다.

port
Int32

address와 연결된 포트 번호이거나, 사용할 수 있는 포트를 지정할 경우 0입니다. port는 호스트 순서로 지정됩니다.

예외

portMinPort보다 작은 경우

또는

portMaxPort보다 큰 경우

또는

address가 0보다 작거나 0x00000000FFFFFFFF보다 큰 경우

예제

다음 예제에서는 지정된 IP 주소 및 포트 번호를 사용하여 를 만듭니다 IPEndPoint.

C#

IPAddress hostIPAddress1 = (Dns.Resolve(hostString1)).AddressList[0];
Console.WriteLine(hostIPAddress1.ToString());
IPEndPoint hostIPEndPoint = new IPEndPoint(hostIPAddress1,80);
Console.WriteLine("\nIPEndPoint information:" + hostIPEndPoint.ToString());
Console.WriteLine("\n\tMaximum allowed Port Address :" + IPEndPoint.MaxPort);
Console.WriteLine("\n\tMinimum allowed Port Address :" + IPEndPoint.MinPort);
Console.WriteLine("\n\tAddress Family :" + hostIPEndPoint.AddressFamily);

적용 대상

IPEndPoint(IPAddress, Int32)

Source:
IPEndPoint.cs
Source:
IPEndPoint.cs
Source:
IPEndPoint.cs

지정된 주소와 포트 번호를 사용하여 IPEndPoint 클래스의 새 인스턴스를 초기화합니다.

C#
public IPEndPoint (System.Net.IPAddress address, int port);

매개 변수

address
IPAddress

IPAddress입니다.

port
Int32

address와 연결된 포트 번호이거나, 사용할 수 있는 포트를 지정할 경우 0입니다. port는 호스트 순서로 지정됩니다.

예외

address이(가) null인 경우

portMinPort보다 작은 경우

또는

portMaxPort보다 큰 경우

예제

C#
// Obtain the IP address from the list of IP addresses associated with the server.
foreach(IPAddress address in host.AddressList)
{
  IPEndPoint endpoint = new IPEndPoint(address, port);

  tempSocket =
    new Socket(endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

  tempSocket.Connect(endpoint);

  if(tempSocket.Connected)
  {
    // Display the endpoint information.
    displayEndpointInfo(endpoint);
    // Serialize the endpoint to obtain a SocketAddress object.
    serializedSocketAddress = serializeEndpoint(endpoint);
    break;
  }
  else
            {
                continue;
            }
        }

적용 대상