[RESOLVED] Is this syntax wrong? Why doesnt this work?
Hello ...
Can someone tell me why this doesnt work?
VB Code:
Dim sthing As New System.Net.Sockets.TcpListener(8788)
Isnt that abover constructor supposed to take in the port value alone too?
Its giving me this error..
Code:
C:\Documents and Settings\Godwin\My Documents\Visual Studio Projects\WindowsApplication7\Form1.vb(65): 'Public Sub New(port As Integer)' is obsolete: 'Use TcpListener(IPAddress localaddr, int port).'
Please help me,Thanks :)
Re: Is this syntax wrong? Why doesnt this work?
I know I can use it like this...
TcpListener(IPAddress localaddr, int port)
but,why isnt it accepting the port alone?
Re: Is this syntax wrong? Why doesnt this work?
It's exactly what it says it is: it's obselete :) To quote MSDN:
NOTE: This member is now obsolete.
Use TcpListener(IPAddress localaddr, int port).
Re: Is this syntax wrong? Why doesnt this work?
Thats what I dont know..what does that mean? Why isnt it accepting a port value though its supposed to accept? its there in the third option..
Re: Is this syntax wrong? Why doesnt this work?
It probably existed in the 1.0 Framework, but has been marked obselete in 1.1, and will probably not be listed as one of the overloads in 2.0...
Re: Is this syntax wrong? Why doesnt this work?
Is it a "probably" or are you sure?
Re: Is this syntax wrong? Why doesnt this work?
It's irrelevant - either way you're never going to be able to use it again :)
Re: Is this syntax wrong? Why doesnt this work?
No,my friend has the same .net2003 and he has used the same in his program..It works perfectly fine.It doesnt work only for me.
Re: Is this syntax wrong? Why doesnt this work?
Well,I dont have his source code to see why and how.But,I think there is a way to use it the way it should be used.
Re: Is this syntax wrong? Why doesnt this work?
What version of the Framework is he using? And you definitely won't be able to use this in the 2.0 Framework.
Re: Is this syntax wrong? Why doesnt this work?
No,we both use the 1.1 framework :)
Re: Is this syntax wrong? Why doesnt this work?
And is he running SP1 of the 1.1 Framework?
Re: Is this syntax wrong? Why doesnt this work?
yes,the same .net2003 with .net 1.1 framework..Hes actively working on .net too
Re: Is this syntax wrong? Why doesnt this work?
Without wanting to put too fine a point on it - a) I don't believe you, and b) Why won't you just listen to MSDN?
Look at:
http://msdn.microsoft.com/library/de...sctortopic.asp
The very first Overload is marked as Obselete. Just use their suggested code:
VB Code:
'Creates an instance of the TcpListener class by providing a local IP address and port number.
Dim ipAddress As IPAddress = Dns.Resolve("localhost").AddressList(0)
Try
Dim tcpListener As New TcpListener(ipAddress, 13)
Catch e As Exception
Console.WriteLine(e.ToString())
End Try
I'm not making any of this up... it's coming straight out of MSDN...
Re: Is this syntax wrong? Why doesnt this work?
You dont believe me?
Well,this is really the problem I am having.I wonder if you got the same error if you pasted the code there.
Im not sure if he has sp1 and stuff..but,he has the same .net2003 with .net1.1 framework
Re: Is this syntax wrong? Why doesnt this work?
I cant specify the ipaddress since I dont know what the ipaddress would be.I thought the other syntax would probably automatically take the ip or something
Re: Is this syntax wrong? Why doesnt this work?
Hey,I guess your right,its probably due to the difference in the version of framework. ;)
Im sorry for the argument :)
Thanks