Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. TcpListener/TcpClient not working!

TcpListener/TcpClient not working!

Scheduled Pinned Locked Moved C#
sysadminquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lord Kixdemp
    wrote on last edited by
    #1

    Hello everyone! I have 2 programs, a server and a client. If I start them both on the same computer, it works flawlessly. However, if I try a computer on the network (which I can do Windows file/printer sharing with) with one of the apps, the client says that the target machine actively refused it. At first I thought it was my router, since I've been having some problems with it lately. But then I used my neighbor's wireless connection with 2 laptops and tried it, no result. So it's got to be my code. Server:

    server = new TcpListener(port); // port: 77
    server.Start();
    

    Client:

    sock = new TcpClient(host, port); // host: 'localhost' or '192.168.0.100'; port: 77
    

    As I said, both programs work fine on the same computer. Does anyone know why this might happen? Maybe my neighbor's router is crappy too? Thanks in advance!

    Windows Calculator told me I will die at 28. :(

    C B 2 Replies Last reply
    0
    • L Lord Kixdemp

      Hello everyone! I have 2 programs, a server and a client. If I start them both on the same computer, it works flawlessly. However, if I try a computer on the network (which I can do Windows file/printer sharing with) with one of the apps, the client says that the target machine actively refused it. At first I thought it was my router, since I've been having some problems with it lately. But then I used my neighbor's wireless connection with 2 laptops and tried it, no result. So it's got to be my code. Server:

      server = new TcpListener(port); // port: 77
      server.Start();
      

      Client:

      sock = new TcpClient(host, port); // host: 'localhost' or '192.168.0.100'; port: 77
      

      As I said, both programs work fine on the same computer. Does anyone know why this might happen? Maybe my neighbor's router is crappy too? Thanks in advance!

      Windows Calculator told me I will die at 28. :(

      C Offline
      C Offline
      cc_wang
      wrote on last edited by
      #2

      I do not know if this can help.... for your information. 1) you can check your window firewall setting. If your firewall is on,you can set the exception for port 77. 2) To get all the listenning ports at server, you can try 'netstat /a' command at Server command prompt. -- To test the connection from client, you can also try 'telnet [hostIP] [port]' command at Client command prompt. Wish u luck.:) ccwang :)

      1 Reply Last reply
      0
      • L Lord Kixdemp

        Hello everyone! I have 2 programs, a server and a client. If I start them both on the same computer, it works flawlessly. However, if I try a computer on the network (which I can do Windows file/printer sharing with) with one of the apps, the client says that the target machine actively refused it. At first I thought it was my router, since I've been having some problems with it lately. But then I used my neighbor's wireless connection with 2 laptops and tried it, no result. So it's got to be my code. Server:

        server = new TcpListener(port); // port: 77
        server.Start();
        

        Client:

        sock = new TcpClient(host, port); // host: 'localhost' or '192.168.0.100'; port: 77
        

        As I said, both programs work fine on the same computer. Does anyone know why this might happen? Maybe my neighbor's router is crappy too? Thanks in advance!

        Windows Calculator told me I will die at 28. :(

        B Offline
        B Offline
        bola_shokry
        wrote on last edited by
        #3

        hi this problem faced me before , and after long time i passed it :) go this link and you find a good discussion about it [http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1099091&SiteID=1](http://forums.microsoft.com/MSDN/ShowPost.aspx?

        <a href=) i hope it work

        L B 2 Replies Last reply
        0
        • B bola_shokry

          hi this problem faced me before , and after long time i passed it :) go this link and you find a good discussion about it [http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1099091&SiteID=1](http://forums.microsoft.com/MSDN/ShowPost.aspx?

          <a href=) i hope it work

          L Offline
          L Offline
          Lord Kixdemp
          wrote on last edited by
          #4

          I use the Windows firewall and PeerGuardian. For the Windows one, I clicked 'Unblock' the first time I ran it, and PG doesn't block it. Netstat gives me this: TCP presser:77 presser:0 LISTENING Wait, shouldn't both the local and foreign addresses be the same? Why is one 77 and the other zero? And bola_shokry, that link didn't work. Any more ideas? Thanks you both!

          Windows Calculator told me I will die at 28. :(

          1 Reply Last reply
          0
          • B bola_shokry

            hi this problem faced me before , and after long time i passed it :) go this link and you find a good discussion about it [http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1099091&SiteID=1](http://forums.microsoft.com/MSDN/ShowPost.aspx?

            <a href=) i hope it work

            B Offline
            B Offline
            bola_shokry
            wrote on last edited by
            #5

            sorry , i tryed the link i found it dont work (i dont know why) anyway , go to MSDN Forums » .NET Development » .NET Framework Networking and Communication » problem in client/server application start the navigation from this link: http://forums.microsoft.com/msdn[^] i know this problem , its boring:mad: sorry again

            L 1 Reply Last reply
            0
            • B bola_shokry

              sorry , i tryed the link i found it dont work (i dont know why) anyway , go to MSDN Forums » .NET Development » .NET Framework Networking and Communication » problem in client/server application start the navigation from this link: http://forums.microsoft.com/msdn[^] i know this problem , its boring:mad: sorry again

              L Offline
              L Offline
              Lord Kixdemp
              wrote on last edited by
              #6

              Well, his problem is kind of different. His computers can see each other on a network, mine can't. :-( But I got something here. I disabled both the Windows Firewall and PeerGuardian and guess what, Apache works. I tried my program but nope, that doesn't work yet. But wait a minute... 'telnet 192.168.0.100 77' gets through! Then how come my client doesn't?! I updated the code:

              IPEndPoint ep = new IPEndPoint(IPAddress.Parse("192.168.0.100"), 77);
              sock = new TcpClient(ep);
              

              But it still isn't working... Ideas? Thanks for helping me!

              Windows Calculator told me I will die at 28. :(

              L 1 Reply Last reply
              0
              • L Lord Kixdemp

                Well, his problem is kind of different. His computers can see each other on a network, mine can't. :-( But I got something here. I disabled both the Windows Firewall and PeerGuardian and guess what, Apache works. I tried my program but nope, that doesn't work yet. But wait a minute... 'telnet 192.168.0.100 77' gets through! Then how come my client doesn't?! I updated the code:

                IPEndPoint ep = new IPEndPoint(IPAddress.Parse("192.168.0.100"), 77);
                sock = new TcpClient(ep);
                

                But it still isn't working... Ideas? Thanks for helping me!

                Windows Calculator told me I will die at 28. :(

                L Offline
                L Offline
                Lord Kixdemp
                wrote on last edited by
                #7

                Nevermind, that wasn't supposed to work. But this is:

                sock = new TcpClient();
                sock.Client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                sock.Connect(host, 77);
                

                Wee, now I can play in 2 computers. Thanks VERY much! ;)

                Windows Calculator told me I will die at 28. :(

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups