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
  1. Home
  2. General Programming
  3. C#
  4. problem with dynamic ips when using sockets.

problem with dynamic ips when using sockets.

Scheduled Pinned Locked Moved C#
sysadminarchitecturehelp
6 Posts 4 Posters 0 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.
  • P Offline
    P Offline
    prasadbuddhika
    wrote on last edited by
    #1

    i'm developing a simple socket application for server client architecture. it works fine when the pc is having a static it , but when the pc is obtaining Ips automatically means when the radio button for "obtain an ip autmatically" , it gives the exception saying this ip is not valid in the context , any idea to address this situation. thanx in advance.

    Y L J 3 Replies Last reply
    0
    • P prasadbuddhika

      i'm developing a simple socket application for server client architecture. it works fine when the pc is having a static it , but when the pc is obtaining Ips automatically means when the radio button for "obtain an ip autmatically" , it gives the exception saying this ip is not valid in the context , any idea to address this situation. thanx in advance.

      Y Offline
      Y Offline
      Yusuf
      wrote on last edited by
      #2

      Can you use machine name instead of IP address. As you indicated the IP address can be changed when it is using dynamic IP setting, where as the machine name stays the same.

      Yusuf May I help you?

      1 Reply Last reply
      0
      • P prasadbuddhika

        i'm developing a simple socket application for server client architecture. it works fine when the pc is having a static it , but when the pc is obtaining Ips automatically means when the radio button for "obtain an ip autmatically" , it gives the exception saying this ip is not valid in the context , any idea to address this situation. thanx in advance.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Which IP address are you referring to here, the local or remote? If it is the remote address then you need to verify that it is consistent with the actual address in use by the remote machine. Perhaps if you show an extract of your code, and what results you are seeing, we can offer some further suggestions.

        I must get a clever new signature for 2011.

        P 1 Reply Last reply
        0
        • P prasadbuddhika

          i'm developing a simple socket application for server client architecture. it works fine when the pc is having a static it , but when the pc is obtaining Ips automatically means when the radio button for "obtain an ip autmatically" , it gives the exception saying this ip is not valid in the context , any idea to address this situation. thanx in advance.

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          In a client server architecture the 'server' IP is traditionally fixed. Not dynamic. In a client server architecture the client connects to the server. If the server IP is not fixed then one must use another mechanism which will require some other server to get the current IP. Host name resolution is one method to do that. It does however require that the host name is being managed by a DNS server.

          1 Reply Last reply
          0
          • L Lost User

            Which IP address are you referring to here, the local or remote? If it is the remote address then you need to verify that it is consistent with the actual address in use by the remote machine. Perhaps if you show an extract of your code, and what results you are seeing, we can offer some further suggestions.

            I must get a clever new signature for 2011.

            P Offline
            P Offline
            prasadbuddhika
            wrote on last edited by
            #5

            thanx for all of you ..! and this is the code segment i use.

                    localIP = Dns.GetHostAddresses(Dns.GetHostName())\[0\];
                    IPEndPoint localEndpoint = new IPEndPoint(localIP, 7575);
                    lSoc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    lSoc.Bind(localEndpoint);
                    lSoc.Listen(10);
            
            L 1 Reply Last reply
            0
            • P prasadbuddhika

              thanx for all of you ..! and this is the code segment i use.

                      localIP = Dns.GetHostAddresses(Dns.GetHostName())\[0\];
                      IPEndPoint localEndpoint = new IPEndPoint(localIP, 7575);
                      lSoc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                      lSoc.Bind(localEndpoint);
                      lSoc.Listen(10);
              
              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              You need to go through this code with your debugger and see exactly what values are being returned for the IP address.

              I must get a clever new signature for 2011.

              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