Results 1 to 17 of 17

Thread: [RESOLVED] Is this syntax wrong? Why doesnt this work?

  1. #1

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Resolved [RESOLVED] Is this syntax wrong? Why doesnt this work?

    Hello ...
    Can someone tell me why this doesnt work?
    VB Code:
    1. 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
    Godwin

    Help someone else with what someone helped you!

  2. #2

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    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?
    Godwin

    Help someone else with what someone helped you!

  3. #3
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    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).
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  4. #4

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    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..
    Godwin

    Help someone else with what someone helped you!

  5. #5
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    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...
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  6. #6

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Is this syntax wrong? Why doesnt this work?

    Is it a "probably" or are you sure?
    Godwin

    Help someone else with what someone helped you!

  7. #7
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    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
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  8. #8

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    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.
    Godwin

    Help someone else with what someone helped you!

  9. #9

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    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.
    Godwin

    Help someone else with what someone helped you!

  10. #10
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    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.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  11. #11

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Is this syntax wrong? Why doesnt this work?

    No,we both use the 1.1 framework
    Godwin

    Help someone else with what someone helped you!

  12. #12
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Is this syntax wrong? Why doesnt this work?

    And is he running SP1 of the 1.1 Framework?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  13. #13

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Is this syntax wrong? Why doesnt this work?

    yes,the same .net2003 with .net 1.1 framework..Hes actively working on .net too
    Godwin

    Help someone else with what someone helped you!

  14. #14
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    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:
    1. 'Creates an instance of the TcpListener class by providing a local IP address and port number.
    2. Dim ipAddress As IPAddress = Dns.Resolve("localhost").AddressList(0)
    3.  
    4. Try
    5.    Dim tcpListener As New TcpListener(ipAddress, 13)
    6. Catch e As Exception
    7.    Console.WriteLine(e.ToString())
    8. End Try

    I'm not making any of this up... it's coming straight out of MSDN...
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  15. #15

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    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
    Godwin

    Help someone else with what someone helped you!

  16. #16

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    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
    Godwin

    Help someone else with what someone helped you!

  17. #17

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    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
    Godwin

    Help someone else with what someone helped you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width