TCPlistener problems


Well-known member
Jun 7, 2004
Wales, UK
Programming Experience
Anybody know why this line dosen't work?

Const[/color][/size][size=2][color=#000000] portNumber [/color][/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#000000] [/color][/size][size=2][color=#0000ff]Integer[/color][/size][size=2][color=#000000] = 8000[/color][/size]
[/color][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] tcpListener [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]New[/color][/size][size=2] TcpListener(portNumber)[/size]

I get the message saying:

'Public Sub New(port As Integer)' is obsolete: 'Use TcpListener(IPAddress localaddr, int port).'

I don't know how to change it so that it does work, any help would be great

You must be using VS 2005?

I beleive it will still work, it's just that it may not in future releases.
I found this in the help files:

[COLOR=Blue]Dim [/COLOR]port [COLOR=Blue]As[/COLOR] Int32 = 13000
[COLOR=Blue]Dim [/COLOR]localAddr [COLOR=Blue]As [/COLOR]IPAddress = IPAddress.Parse("")
[COLOR=Blue]Dim [/COLOR]server [COLOR=Blue]As New[/COLOR] TcpListener(localAddr, port)
Last edited:
Hey..please correct me if i m wrong, but i guess while declaring the localaddress variable, we'll have to use

Dim localaddress As System.Net.IPAddress = System.Net.IPAddress.Parse("")

Hope it works

sorry to bring up an old topic. but im trying to test out a listener for port lets say 65534. when i ru nthis line server.start(). it throughs me my exception. how can i trouble shoot whats going on here. the program will completly freeze if i use:

Dim localAddr As System.Net.IPAddress = System.Net.IPAddress.Parse("")

but if i use:
Dim localAddr As System.Net.IPAddress = System.Net.IPAddress.Parse("")
it doesnt freeze just throughs an exception.
any help?

i tried shutting down my firewall. could it be cause of my router?
Well, just a guess but the IP address, is that the IP address of your router? It's the default of many routers. Thus you cant listen to another computers (or routers) port remotely. Are you sure the exception is being flagged up at this point? Try using some break pointers to single out exactly where the exception is given, or give more of your code for us to see.