Help Parsing String into an ip address

This is a discussion on Help Parsing String into an ip address within the C# Programming forums, part of the General Programming Boards category; So im trying to parse a string into a Ip Address but i have a problem, the IPAddress.Parse method only ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    35

    Help Parsing String into an ip address

    So im trying to parse a string into a Ip Address but i have a problem, the IPAddress.Parse method only works for ipv4 address's how do i parse ANY Ip address into a string, if i use the IPaddress.Parse method on my public(remote) IP it throws an exception but on ipv4 local ip it doesn't how do i parse ANY ip address the user inputs as a string as an Ip Address? Please help

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,163
    What specifically is it failing on? It should work just fine. Try your question again, this time with proper grammar. I can barely tell what you're having problems with.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Sep 2012
    Posts
    48
    Holy balls. After you type a sentence and put a period, you make a space. Take my syntax as an example. Seriously, that was painful as hell to read.

  4. #4
    Registered User
    Join Date
    Mar 2009
    Location
    england
    Posts
    209
    You mention your local IP address being ipv4, so I'm assuming your "public(remote)" ip address is ipv6? I've never used ipv6 before, but a quick test...

    Code:
    // a random ipv6 address
    String test_ip = "2001:0db8:85a3:0042:0000:8a2e:0370:7334";
    // convert to IPAddress object
    IPAddress test_addr = IPAddress.Parse(test_ip);
    // confirm it worked?
    Console.Write(test_addr);
    ...showed the IPAddress object as being capable of supporting this feature. I can only suggest that you are inputting a badly formatted ip address. Perhaps you could provide an example of a user input which throws the exception?

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596

  6. #6
    Registered User
    Join Date
    Nov 2011
    Posts
    35
    Thanks guys, the problem was bad input, i apologize for the grammatical errors in my post!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Parsing a string
    By sigur47 in forum C Programming
    Replies: 4
    Last Post: 05-06-2012, 04:30 AM
  2. Parsing a string to get the ip address
    By steve1_rm in forum C++ Programming
    Replies: 2
    Last Post: 12-08-2011, 11:02 AM
  3. String parsing(parsing comments out of HTML file)
    By slcjoey in forum C# Programming
    Replies: 0
    Last Post: 07-29-2006, 08:28 PM
  4. Parsing a string
    By robin171 in forum C Programming
    Replies: 22
    Last Post: 10-20-2005, 10:44 AM
  5. string parsing
    By WizardOfOz in forum C Programming
    Replies: 16
    Last Post: 08-25-2005, 08:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21