Results 1 to 8 of 8

Thread: Winsock LocalIP is not the correct IP

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2020
    Posts
    17

    Winsock LocalIP is not the correct IP

    There is a winsock app that works between two computers over the internet which has not gotten the IP address correctly from either machine. I use proxy most of the time which gives and ip address which doesn't match with the ip found online and if im off proxy the it would only appear it knows the local ip address to the router versus the ip generated by the dhcp. Its the same effect from either pc. So I can't use this winsock app unless I can set the ip address to send from. The remote ip is possible to enter. BinaryTransfer.zip

  2. #2
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,730

    Re: Winsock LocalIP is not the correct IP

    I remember I did have this issue +10 years ago when I worked on that.
    the IP returned was the internal one (not the localhost) but I needed the one that was connectable from internet.
    theres a way with a couple API that would do that, but I dont have access to my "old tools" here, I think I have that at home, so if nobody can help u I will dig it up on Wednesday.

  3. #3
    Hyperactive Member
    Join Date
    Jan 2018
    Posts
    268

    Re: Winsock LocalIP is not the correct IP

    I'm probably missing something here, but unless you are just binding your listener to the wrong adapter or network, it doesn't sound like there is a solution without going through a third machine. At least one of your IPs needs to be known and routable after all.

  4. #4
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,730

    Re: Winsock LocalIP is not the correct IP

    to get the internal ip (not the localhost), is easy, but to get the ip that the outsider need to have to be able to connect to you is another thing.
    I remember this issue when I worked on that 10+ years ago. Tomorrow when I get home I will dig up if I can find that function that gives u that IP.
    of course, if both machines are "passive", there can not be a connection, one need to be "active" or u need a 3rd machine that acts like a tunnel between the two passive machines.

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Winsock LocalIP is not the correct IP


  6. #6
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,730

    Re: Winsock LocalIP is not the correct IP

    I did try the code and it doesn't work with windows 7. it seems the API calls will only work on the private IP, not external. I remember it worked on XP, could be something is changed or I was just lucky when I used it back in the day.
    better try your luck with the link dilettante posted.
    grab the IP from a site, theres numerous sites that offer your IP.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Oct 2020
    Posts
    17

    Re: Winsock LocalIP is not the correct IP

    Binding the right IP is the problem

  8. #8
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: Winsock LocalIP is not the correct IP

    Quote Originally Posted by Tert View Post
    Binding the right IP is the problem
    The problem is the link to the ZIP in your OP is very hard to notice! I'm posting a link to the original Planet Source Code submission you are having troubles with for the rest of the members to ponder on: A sample to transfer binary through winsock at very very high speed (Meet industrial standard)

    Now, let's clear something about IP connections between two peers

    Code:
      P1  | <----> |  P2
    There are *four* IP addresses involved here (not just two) like this

    Code:
      P1  |        |  P2
    -----            -----
    IP-A1 | -----> | IP-A2
    IP-B2 | <----- | IP-B1
    Both P1 and P2 have *different* view on the connection between them, and P1 thinks the connection is between IP-A1 and IP-A2 while P2 thinks the connection is betwen IP-B1 and IP-B2

    So which IP address do you need to know?

    cheers,
    </wqw>

    p.s. Btw, posting executables in this forum is not allowed.

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