Vb.Net IPAddress.Parse Slow ?

M

marciocamurati

Hi everyone !

I use at my project the socket to make connections between Pda's and
now I make any tests to find where is the Pda that open the port to
receive the connection, I try the IPAddress.Parse but for my surprise
it's very slow to response, at my other test I resolve the DNS
Dns.Resolve and it's faster then the direct parse. Before make this
tests I wait that the Parse was be more and more faster than resolve
the DNS. My tests are correct, the parse at the VB.Net CF is very slow
?

Code:
{Parse}
....
Dim hostAdd As IPAddress = IPAddress.Parse("10.0.0." & ipRangeAtual)
....

Code:
{Resolve}
....
hostEntry = Dns.Resolve(tempHost)
hostAdd = hostEntry.AddressList(0)
....

Code:
{Other}
If Not hostAdd Is Nothing Then
Dim ipHost As IPEndPoint = New IPEndPoint(hostAdd, porta)
Dim socket As Socket

Try
socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream,
Sockets.ProtocolType.Tcp)

Dim lingerOption As LingerOption = New LingerOption(True, 1)
socket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.Linger, lingerOption)

Catch ex As Exception
status = False
End Try
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top