Results 1 to 10 of 14

Thread: using host_addr, hostip_toname, hostname_toip

Hybrid View

  1. #1
    Member
    Join Date
    Jan 2018
    Location
    France
    Age
    65
    Posts
    40
    Rep Power
    5

    using host_addr, hostip_toname, hostname_toip

    Hi,

    I'm looking to use host_addr and I receive a run time error popup

    saying "HOST_ADDR" variable not defined or mispelled keyword

    I guess I have to
    uses "the good module"
    
    But the help pages does not indicate the name of the needed module

    I tried
    uses "inet"
    uses "lan"
    
    without success.

    Please . . . . .

    Regards,

    Dany
    Last edited by dco045; 28-01-2018 at 22:55.

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    51
    Posts
    8,311
    Blog Entries
    2
    Rep Power
    10
    Check \SampleScripts\INet\INet_GetIPs.tBasic
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    51
    Posts
    8,311
    Blog Entries
    2
    Rep Power
    10
    Module is iNet
    Your computer can have multiple network cards and cards can be activate/deactivated on the fly. For example if you connect to WiFi networks or you activate a VPN over a network.

    Uses "inet"Uses "Console"
    
    
    Long lCount
    
    
    While %true
      PrintL "Number of interfaces present:", INET_GetInterfaces
      PrintL "------------------------------------------"
      
      PrintL "-##-[IP           ] [SubNet       ] [Type]"
      PrintL "------------------------------------------"
      For lCount = 1 To INET_GetInterfaces
        PrintL  Format$(lCount, " 00"), _
                Using$("\             \", INET_GetIp(lCount)), _
                Using$("\             \", INET_GetSubNet(lCount)), _
                Format$(INet_GetIpType(lCount), "0000")
      Next
      
      PrintL "------------------------------------------"
      PrintL
      PrintL " Press [ESC] to finish"
      PrintL " 4 seconds for the next auto refresh  "
      PrintL " any key to refresh "
      PrintL "------------------------------------------"
      If WaitKey(4) = "[ESC]" Then Exit While
      Cls
    Wend
    
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  4. #4
    Member
    Join Date
    Jan 2018
    Location
    France
    Age
    65
    Posts
    40
    Rep Power
    5
    Hi Eros,

    Your example works fine. But what about functions :

    n = HOST_ADDR [(nIndex)]
    
    s = HOSTIP_TONAME(nIP)
    
    n = HOSTNAME_TOIP(sHost)
    
    as they appear in online and offline Helpfiles ?

    Regards,

    Dany

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    51
    Posts
    8,311
    Blog Entries
    2
    Rep Power
    10
    If you press F1 while above a keyword you should get help about that keyword.
    Help should say which module that keyword is inside.
    The mentioned functions are inside TcpUdp module.
    TcpUdp module implements some functionalities to create a Tcp or Udt server or use Tcp or Udp protocol to connect to a server that exposes some functionality over network.
    There are some scripts inside \SampleScripts\TcpUdp\ directory that can show how to create a network communication using Tcp and Udp

    Example on your mentioned functions:
    uses "TcpUdp"uses "Console"
    
    
    string sHost = "www.google.com"
    Long nIp
    
    
    nIp = HOSTNAME_TOIP(sHost)                      '---How your DNS resolve a host name
    printl "HOSTNAME_TOIP of", sHost, "is", nIp
    printl "IP_ToString is", IP_ToString(nIp)       '---Translate Ip address into human one
    printl "HOSTIP_TONAME is", HOSTIP_TONAME(nIp)   '---How your DNS knows the ip
    WaitKey
    
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  6. #6
    Member
    Join Date
    Jan 2018
    Location
    France
    Age
    65
    Posts
    40
    Rep Power
    5
    Quote Originally Posted by ErosOlmi View Post
    If you press F1 while above a keyword you should get help about that keyword.
    Help should say which module that keyword is inside.
    The mentioned functions are inside TcpUdp module.
    TcpUdp module implements some functionalities to create a Tcp or Udt server or use Tcp or Udp protocol to connect to a server that exposes some functionality over network.
    There are some scripts inside \SampleScripts\TcpUdp\ directory that can show how to create a network communication using Tcp and Udp

    Example on your mentioned functions:
    uses "TcpUdp"uses "Console"
    
    
    string sHost = "www.google.com"
    Long nIp
    
    
    nIp = HOSTNAME_TOIP(sHost)                      '---How your DNS resolve a host name
    printl "HOSTNAME_TOIP of", sHost, "is", nIp
    printl "IP_ToString is", IP_ToString(nIp)       '---Translate Ip address into human one
    printl "HOSTIP_TONAME is", HOSTIP_TONAME(nIp)   '---How your DNS knows the ip
    WaitKey
    
    HI Eros,
    But the reason I posted on these function is that the relevant

    uses "tcpudp"
    
    doesn't appear in help files either online or offline.

    As I said in my PM of 21 january, I begin using ThinBasic and I make huge use of help files, and before disturbing TB developpers , be sure that, I try, try, press F1, read help, look in SamplesScripts. My F1 key is completely worn out.
    So for this precise case, help files may be completed.


    Regards,


    Dany
    Last edited by dco045; 31-01-2018 at 13:15.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •