Pergunta

i am trying to make a simple chat program in VB.net but when I define a tcplistener as any tutorial has done by:

  Dim Listener As New TcpListener(6335)

i get the error message:

Public Sub New(port As Integer)' is obsolete: 'This method has been deprecated. Please use TcpListener(IPAddress localaddr, int port) instead. http://go.microsoft.com/fwlink/?linkid=14202'.

i do not understand the purpose behind this new way of doing it but I also do not know how to both get the local address and use the data type "IPaddress" can anybody explain?

Foi útil?

Solução

I don't know why it's obsolete, but this is how one create an instance of IpAdresse.

Dim ip As IPAddress = IPAddress.Parse("0.0.0.0")
Dim port As Integer = 6335
Dim listener As New TcpListener(ip, port)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top