Results 1 to 9 of 9

Thread: Knowing Ip address of my client

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Posts
    198

    Knowing Ip address of my client

    Hi, I need to know IP address of my clients applications. I thought that i could get them by RemoteEndPOint, but when I did some test, I realized that I won't be able to do it through that way. This is what I did (just as an example):

    Dim IP As New IPEndPoint("127.0.0.1", 8050)

    IP.ToString 'Returns 25.240.1.0:8050

    IP.Address.ToString 'Returns 25.240.1.0

    IP.Address.Address.ToString 'Returns 127001


    So, noting that I don't have any way to get the ip address from an IPEndPoint, how can i know it?. Another thing I don't understand is if I created an IPEndPoint with 127.0.0.1 as IPAddress, why it returns 25.240.1.0?.

    Thank you very much.

  2. #2
    Addicted Member Phreak's Avatar
    Join Date
    Oct 2005
    Location
    Netherlands
    Posts
    132

    Re: Knowing Ip address of my client

    I did this a couple of times in VB6, but i dont know all the functions of .Net yet.

    Anyway, i did this by fetching the ip address from http://Whatismyip.com and then
    send it to my "server" app...
    If i gave you good code/help, then dont forget to RATE
    Dont forget to mark your thread [Resolved] with the tools from the menu above...

  3. #3
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Knowing Ip address of my client

    It's probably getting the IP address attached to your network adapter. Try this. Go to Start -> Run and type in 'cmd' and press return. Now type in ipconfig. The IP addresses that it lists, is one of them the 25.240.x.x address?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Posts
    198

    Re: Knowing Ip address of my client

    Hi, thanks for answer.
    Phreak: How did you do that? Did you need some kind of HTML parser or something like that?
    Kasracer: No, none of them is that ip address. Isn't that weird?

    Regards!.

  5. #5
    Addicted Member Phreak's Avatar
    Join Date
    Oct 2005
    Location
    Netherlands
    Posts
    132

    Re: Knowing Ip address of my client

    Well i added i downloaded the source from the whatismyip site to a textbox
    (can also be a string) and then i extracted the ip address from the HTML source.
    And then i had the IP address


    #Phreak
    If i gave you good code/help, then dont forget to RATE
    Dont forget to mark your thread [Resolved] with the tools from the menu above...

  6. #6
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: Knowing Ip address of my client

    To answer the second question, IPEndPoint doesn't accept the string notation of the IP address. It's assuming that the value you passed is in the long format.

    If you want to use the string format in the constructor, you need to parse it:

    Dim IP As New IPEndPoint(net.ipaddress.parse("127.0.0.1"), 8050)
    Last edited by sevenhalo; Dec 15th, 2005 at 11:30 AM.

  7. #7
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Knowing Ip address of my client

    are you taking into account that they might be behind a router and the IP address assigned to the PC could be a local internal IP, and not the actual WAN IP? This is usually the case these days.

  8. #8
    Addicted Member Phreak's Avatar
    Join Date
    Oct 2005
    Location
    Netherlands
    Posts
    132

    Re: Knowing Ip address of my client

    kleinma is right.... *(Again )*
    If i gave you good code/help, then dont forget to RATE
    Dont forget to mark your thread [Resolved] with the tools from the menu above...

  9. #9
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: Knowing Ip address of my client

    If you would rather do your own conversion, this should help you out.

    Also, if you use the example I gave, tostring will give you your "127.0.0.1" and GetHashCode will give you the long format (16777343).

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