IPEndPoint

  • Thread starter Thread starter James Proctor
  • Start date Start date
J

James Proctor

Hi there, im trying to write a application that has some
socket stuff in. Ive only don socket stuff in vb 6
before. In .net i was using IPEndPoint and i want to
enter an ip address and port like so:

IPEndPoint = New IPEndPoint("192.0.0.01",1000)

But its asking for the IPaddress to be a long. How do i
convert it or put in an IP address of my choice. Hope
someone can help me out.

Regards

James
 
James Proctor said:
Hi there, im trying to write a application that has some
socket stuff in. Ive only don socket stuff in vb 6
before. In .net i was using IPEndPoint and i want to
enter an ip address and port like so:

IPEndPoint = New IPEndPoint("192.0.0.01",1000)

But its asking for the IPaddress to be a long. How do i
convert it or put in an IP address of my choice. Hope
someone can help me out.

The constructor is overloaded.
 
James,

Try:

Dim IPHost As IPHostEntry = Dns.Resolve(m_sHostName)
Dim Aliases() As String = IPHost.Aliases
Dim Addr() As IPAddress = IPHost.AddressList

IPEndPoint = New IPEndPoint(Addr(0), 1000)

m_sHostName can be an IP address or URL.

Steve
 
* "James Proctor said:
socket stuff in. Ive only don socket stuff in vb 6
before. In .net i was using IPEndPoint and i want to
enter an ip address and port like so:

IPEndPoint = New IPEndPoint("192.0.0.01",1000)

But its asking for the IPaddress to be a long. How do i
convert it or put in an IP address of my choice. Hope
someone can help me out.

There is an overloaded ctor available which expects an IP Address:

\\\
Public Sub New(IPAddress, Integer)
///
 
Hi there, im trying to write a application that has some
socket stuff in. Ive only don socket stuff in vb 6
before. In .net i was using IPEndPoint and i want to
enter an ip address and port like so:

IPEndPoint = New IPEndPoint("192.0.0.01",1000)

But its asking for the IPaddress to be a long. How do i
convert it or put in an IP address of my choice. Hope
someone can help me out.

Regards

James

Dim ep As IPEndPoint = New IPEndPoint( _
IPAddress.Parse("192.0.0.01"), 1000)

HTH
 
Back
Top