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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Invalid IP

Invalid IP

Scheduled Pinned Locked Moved C#
4 Posts 3 Posters 1 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.
  • B Offline
    B Offline
    bar3000
    wrote on last edited by
    #1

    Hi, I built an application using a TCP/IP connection. Therefore I need an I.P. checker to make sure the given IP is correct. I noticed that when an invalid IP is provided the complier can tell it right away. SO my quesion is if there is a command to check if an IP address is valid. By valid I mean it is less than 255.255.255.255. Or if you happen to have a code that does it i would be greatful. Thank you in advance :)

    L 0 B 3 Replies Last reply
    0
    • B bar3000

      Hi, I built an application using a TCP/IP connection. Therefore I need an I.P. checker to make sure the given IP is correct. I noticed that when an invalid IP is provided the complier can tell it right away. SO my quesion is if there is a command to check if an IP address is valid. By valid I mean it is less than 255.255.255.255. Or if you happen to have a code that does it i would be greatful. Thank you in advance :)

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, I haven't tried it myself but I would go for IPAddress.TryParse() :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


      1 Reply Last reply
      0
      • B bar3000

        Hi, I built an application using a TCP/IP connection. Therefore I need an I.P. checker to make sure the given IP is correct. I noticed that when an invalid IP is provided the complier can tell it right away. SO my quesion is if there is a command to check if an IP address is valid. By valid I mean it is less than 255.255.255.255. Or if you happen to have a code that does it i would be greatful. Thank you in advance :)

        0 Offline
        0 Offline
        0x3c0
        wrote on last edited by
        #3

        You could either ping it (requires internet access), use a regular expression, invoke the IPAddress.TryParse method or split it, and use Byte.TryParse on each of the components

        1 Reply Last reply
        0
        • B bar3000

          Hi, I built an application using a TCP/IP connection. Therefore I need an I.P. checker to make sure the given IP is correct. I noticed that when an invalid IP is provided the complier can tell it right away. SO my quesion is if there is a command to check if an IP address is valid. By valid I mean it is less than 255.255.255.255. Or if you happen to have a code that does it i would be greatful. Thank you in advance :)

          B Offline
          B Offline
          bar3000
          wrote on last edited by
          #4

          Thanks, used IPAddress.TryParse() worked fine for me.

          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