PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2010 Tcplistener not.... listening?-VBForums
Results 1 to 10 of 10

Thread: Tcplistener not.... listening?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2011
    Posts
    28

    Exclamation Tcplistener not.... listening?

    Hi guys, I have a problem.
    I have a tcplistener listening on port 8500 and a background worker accepting a client. The program works fine on the server computer, but when I telnet to port 8500 on another PC it doesn't work. How may I do that? Im guessig it is a firewall problem but both PCs are connected on the same network. How would I set up something like this?


    Thanks in advance,
    Farrow

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Jun 2011
    Posts
    28

    Post Re: Tcplistener not.... listening?

    I also forgot to mention that both PCs are running Windows 7.

  3. #3
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Pointless Forest 38.517,-92.023
    Posts
    9,213

    Re: Tcplistener not.... listening?

    Code?

    Telnet is not the same as TCP.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2011
    Posts
    28

    Re: Tcplistener not.... listening?

    Public tcp = New System.Net.Sockets.TcpListener(8500)
    tcp.Start()

    ...in the background worker
    tcp.AcceptTcpClient()

  5. #5
    Lively Member
    Join Date
    May 2010
    Posts
    103

    Re: Tcplistener not.... listening?

    Are you trying to connect using your local IP, public IP, or what?

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jun 2011
    Posts
    28

    Re: Tcplistener not.... listening?

    The server is 192.168.1.105, which is what Im trying to connect to. If it helps, here is my telnet command:
    telnet 192.168.1.105 8500
    I am using local IP.
    Again, this works on the server using localhost but, oddly enough, telnetting to 192.168.1.105 from the server itself does not yield a connection. Doing a ipconfig and a nmap scan both revealed that that is actually the ip of the server. At this point I am sure it is a firewall problem, but i dont know.

  7. #7
    Lively Member
    Join Date
    May 2010
    Posts
    103

    Re: Tcplistener not.... listening?

    I did some tests of my own and I found that you have to specify the IP of the listener.

    vb Code:
    1. Dim IP As IPAddress = IPAddress.Parse("127.0.0.1")
    2.         Dim PORT As Integer = 8500
    3.         Dim Listener As New TcpListener(IP, PORT)
    4.         Listener.Start()

    The above would only work when I ran telnet on the server. However to telnet from another computer on the network to the server I had to specify the IP address like this:

    vb Code:
    1. Dim IP As IPAddress = IPAddress.Parse("192.168.1.105")
    2.         Dim PORT As Integer = 8500
    3.         Dim Listener As New TcpListener(IP, PORT)
    4.         Listener.Start()


    I did NOT have to port forward, or turn my firewall off. Also, It's best you don't hardcode the IP and get the local IP on the fly.

  8. #8
    Lively Member
    Join Date
    May 2010
    Posts
    103

    Re: Tcplistener not.... listening?

    Just wanted to add... In VS2008 it gives an error when only supplying a port to the listener, saying that the method has been deprecated. So it's best you supply an IP and a Port like my examples above.


    Warning 1 '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'.

  9. #9
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Pointless Forest 38.517,-92.023
    Posts
    9,213

    Re: Tcplistener not.... listening?

    Lets say that you get the ports set up correctly and are able to telnet address 8500. Are you prepared for the messages that telnet expects to send and receive responses for?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jun 2011
    Posts
    28

    Smile Re: Tcplistener not.... listening?

    I do not plan on using Telnet as the client. I am simply using telnet to connect to my PC to verify it is working. There will be a client portion of the program soon, though.


    @1 above, thanks alot for your solution. I'm sorry if this is asking too much but... how would I programatically go about finding the local IP of the server?



    Thanks to all who have helped so far. I believe I am nearing the solution.

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width