CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2010
    Posts
    33

    winsock problem - can't connect from outside?

    Hi,

    I have a server and client programs using TCP/IP.
    I was always able to connect with no errors when i used the IPv4 that i get with the /ipconfig command (192.168.9...) but when i replace it with my IP that i get from whatismyip.com my connection (which is non-blocking) times-out and fails.
    I've also tried to connect from a different pc on other network with both IPs and it timed-out as well...
    How's that possible?

    Thanks!

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: winsock problem - can't connect from outside?

    Probably a router/firewall issue. For this kind of issues I usually post this link http://slacksite.com/other/ftp.html that pretty much explains it.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Sep 2010
    Posts
    33

    Re: winsock problem - can't connect from outside?

    i see.. thanks!
    so here's my problem:
    i am behind a router, but i can't configure it, since it's not mine personally. so other than asking the admin to open a port for me (coz he won't), is there a way to check if there are any open ports i can use?

  4. #4
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: winsock problem - can't connect from outside?

    No what you need is a static route to your computer and that is set up in the router. I've never used it since I'm in control of my router but I think you could use uPnP (http://en.wikipedia.org/wiki/UPnP) if it's enabled in the router.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  5. #5
    Join Date
    Sep 2010
    Posts
    33

    Re: winsock problem - can't connect from outside?

    well, i've read wikipedia and searched more in google but i still couldn't understand how's that can help me running a server behind a router which i don't have access to..?

  6. #6
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: winsock problem - can't connect from outside?

    Well I've never used so I don't know either but it should be possible if uPnP is enabled. http://www.google.se/#hl=sv&source=h...7e43602e02c461

    If it's not then you have to find some workaround, maybe tunneling would work for your application http://www.google.se/#hl=sv&biw=1449...7e43602e02c461
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  7. #7
    Join Date
    Sep 2010
    Posts
    33

    Re: winsock problem - can't connect from outside?

    ok i'll check it out, thanks alot!

  8. #8
    Join Date
    Oct 2010
    Posts
    68

    Re: winsock problem - can't connect from outside?

    Get with your ISP they may be able to help you with the issue. You need to configure your router(assuming your router has the internet IP address) to forward requests it recieves on your application port to your server(which is behind your router, on your LAN).

    So basically, assume your router's internet IP is 79.112.92.43(completely random) and your server has a local IP address of 192.168.1.5 and uses port 6464. You need to tell your router "When you receive a request on port 6464, you need to forward it to this local address: 192.168.1.5"

    The term is 'Port Forwarding' and will give you some good Google results. You will also need to get with your ISP and ensure that your router does indeed have an internet IP(usually the case) and you are not inside their local network(possible if you are paying for internet inside of apartment buildings or college dorms). If you do not have an internet IP address then your ISP will have to do the port forwarding for you.





    EDIT****

    Sorry, I didn't see the comment about your admin not opening a port for you. Unfortunately if your admin will not do the Port Forwarding for you the router will not know what to do with incoming packets, and will consequently drop them.
    Last edited by Austin.Soucy; January 7th, 2011 at 10:44 AM.

  9. #9
    Join Date
    Sep 2010
    Posts
    33

    Re: winsock problem - can't connect from outside?

    yea, i finally got that port forwarding issue.. thanks

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

Featured