Search code examples
vb.netruntime-errorudpclient

Error on Endpoint creation


I get the error La conversión de la cadena 127.0.0.1 en el tipo 'Long' no es válida.

on the line

Dim EndPoint As New System.Net.IPEndPoint(Host, CInt(Port))

I'm trying to create an UDPClient to send data to an application on the same server that is listening on a specific UDP port.

I tried the application in mi PC and works ok and the IP seems to be correct.

What can be wrong?


Solution

  • Added some code to convert the IP in the string based on the question How to convert IP Address to IP HostEntry in VB.NET?

    Dim myNewIP As System.Net.IPAddress
    myNewIP = System.Net.IPAddress.Parse(Host)
    Dim EndPoint As New System.Net.IPEndPoint(myNewIP, CInt(Port))