Announcement

Collapse
No announcement yet.

Retrieving IP Address

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Retrieving IP Address

    Okay in PB 6.0 it says to retreive your own IP address use:

    Code:
    HOST ADDR "" TO ip&
    Which works fine, but the problem is it doesn't retrieve the
    right IP address. I have a DSL connection and for some reason
    it retreives the IP for my Ethernet card and not the IP for
    my service. Has anyone else had this problem and does anyone
    know how to get the IP of your connection and not of the
    Ethernet card.

    Please help!



    ------------------
    Thank you,
    Ryan M. Cross
    Head Webmaster Nofee Inc. Internet Services
    President Likuid Creations Ltd.

    Thank you,
    Ryan M. Cross

  • #2

    The HOST ADDR command is capable of retrieving multiple addresses with an index passed after it.

    Try This...

    Code:
    For x& = 0 TO 2
       Host Addr(x&) "" To y&(x&)
       MessageBox "Address " & Format$(x&) & " is " & IpToString(y&(x&))
    Next x&
    Each Idex used after HOST ADDR will retrieve each devices IP address on a given computer.

    Hope this helps.


    ------------------
    Scott Slater
    Summit Computer Networks, Inc.
    www.summitcn.com

    Comment


    • #3
      thank you very much worked like a charm, maybe you can help me with
      my second problem:
      http://www.powerbasic.com/support/pb...ead.php?t=2536

      thanks a bunch scott!

      ------------------
      thank you,
      ryan m. cross
      webmaster flexifish inc. uk
      likuid creations inc.
      Thank you,
      Ryan M. Cross

      Comment


      • #4
        The index is the key, but how do you enumerate the valid range of the index? If you exceed its valid range, you get a bunch of nonvalid IP addresses, and then a Gerneral Protection Fault.

        For example, in my machine right now I have two ethernet cards.

        If I run this code:

        FOR Index& = 1 TO 10
        HOST ADDR (Index&) TO Temp
        IF ERR THEN GOTO Outloop
        #DEBUG PRINT IpToString(Temp)
        NEXT Index&
        Outloop:


        I trigger a General Protection Fault when Index&=6.

        The DEBUG window displays

        24.13.211.16
        192.168.0.1
        107.98.46.110
        101.46.109.101
        100.105.97.111

        The first two IP addressess (24.13.211.16, 192.168.0.1) are correct. That last 3 are junk. If I have no prior knowledge of how many IP addresses the machine should have, how can I ascertain the valid range for Index& ?

        ------------------
        Michael Burns

        Comment


        • #5
          with dave's help:
          http://www.powerbasic.com/support/pb...ad.php?t=24767

          the "programming the internet" forum has many tips along this line.

          ------------------
          dennis
          mailto:[email protected][email protected]</a>

          [this message has been edited by dennis pearson (edited august 15, 2000).]

          Comment


          • #6
            I tried using Dave' example at the bottom for retreving the
            active IP, but it jsut returns 0.

            ------------------
            Thank you,
            Ryan M. Cross
            Webmaster FlexiFish Inc. UK
            Likuid Creations Inc.
            Thank you,
            Ryan M. Cross

            Comment


            • #7
              N/M got it to work.

              ------------------
              Thank you,
              Ryan M. Cross
              Webmaster FlexiFish Inc. UK
              Likuid Creations Inc.
              Thank you,
              Ryan M. Cross

              Comment

              Working...
              X