TCPlistener problems

levyuk

Well-known member
Joined
Jun 7, 2004
Messages
313
Location
Wales, UK
Programming Experience
3-5
Anybody know why this line dosen't work?

VB.NET:
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]
[size=2]


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

 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
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:

VB.NET:
[COLOR=Blue]Dim [/COLOR]port [COLOR=Blue]As[/COLOR] Int32 = 13000
[COLOR=Blue]Dim [/COLOR]localAddr [COLOR=Blue]As [/COLOR]IPAddress = IPAddress.Parse("127.0.0.1")
[COLOR=Blue]Dim [/COLOR]server [COLOR=Blue]As New[/COLOR] TcpListener(localAddr, port)
 
Last edited:

aalok

New member
Joined
Mar 5, 2005
Messages
3
Programming Experience
5-10
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("127.0.0.1")

Hope it works

Aalok
 

keko2004

Active member
Joined
Feb 13, 2006
Messages
39
Location
Middle Village, NY
Programming Experience
1-3
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("127.0.0.1")

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

i tried shutting down my firewall. could it be cause of my router?
 

p_nivalis

Active member
Joined
Oct 1, 2004
Messages
33
Programming Experience
5-10
Well, just a guess but the 192.168.1.1 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.

P
 
Top Bottom