指定したアドレスとポート番号を使用して、IPEndPoint クラスの新しいインスタンスを初期化します。
名前空間: System.Net
アセンブリ: System (system.dll 内)
構文
'宣言
Public Sub New ( _
address As IPAddress, _
port As Integer _
)
'使用
Dim address As IPAddress
Dim port As Integer
Dim instance As New IPEndPoint(address, port)
public IPEndPoint (
IPAddress address,
int port
)
public:
IPEndPoint (
IPAddress^ address,
int port
)
public IPEndPoint (
IPAddress address,
int port
)
public function IPEndPoint (
address : IPAddress,
port : int
)
パラメータ
- address
IPAddress。
- port
address と関連付けられたポート番号。または、任意のポートを利用できるように 0 に指定されたポート番号。port は、ホスト順です。
例外
例外の種類 | 条件 |
---|---|
port が MinPort より小さい。 または port が MaxPort より大きい。 または address が 0 未満か、0x00000000FFFFFFFF よりも大きい値です。 |
使用例
' Obtain the IP address from the list of IP addresses associated with the server.
Dim address As IPAddress
For Each address In host.AddressList
Dim endpoint As New IPEndPoint(address, port)
tempSocket = New Socket(endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
tempSocket.Connect(endpoint)
If tempSocket.Connected Then
' Display the endpoint information.
displayEndpointInfo(endpoint)
' Serialize the endpoint to obtain a SocketAddress object.
serializedSocketAddress = serializeEndpoint(endpoint)
Exit For
End If
Next address
// 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;
}
// Obtain the IP address from the list of IP addresses associated with the server.
System::Collections::IEnumerator^ myEnum = host->AddressList->GetEnumerator();
while ( myEnum->MoveNext() )
{
IPAddress^ address = safe_cast<IPAddress^>(myEnum->Current);
IPEndPoint^ endpoint = gcnew IPEndPoint( address,port );
tempSocket = gcnew 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;
}
// Obtain the IP address from the list of IP addresses
// associated with the server.
for (int iCtr = 0; iCtr < host.get_AddressList().length; iCtr++) {
IPAddress address = host.get_AddressList()[iCtr];
IPEndPoint endpoint = new IPEndPoint(address, port);
tempSocket = new Socket(endpoint.get_AddressFamily(),
SocketType.Stream, ProtocolType.Tcp);
tempSocket.Connect(endpoint);
if (tempSocket.get_Connected()) {
// Display the endpoint information.
DisplayEndpointInfo(endpoint);
// Serialize the endpoint to obtain a SocketAddress object.
serializedSocketAddress = SerializeEndpoint(endpoint);
break;
}
else {
continue;
}
}
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
.NET Compact Framework
サポート対象 : 2.0、1.0