Results 1 to 10 of 14

Thread: using host_addr, hostip_toname, hostname_toip

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member
    Join Date
    Jan 2018
    Location
    France
    Age
    71
    Posts
    69
    Rep Power
    13

    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
    57
    Posts
    8,782
    Rep Power
    10
    Check \SampleScripts\INet\INet_GetIPs.tBasic
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,782
    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/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  4. #4
    Member
    Join Date
    Jan 2018
    Location
    France
    Age
    71
    Posts
    69
    Rep Power
    13
    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
    57
    Posts
    8,782
    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/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  6. #6
    Member
    Join Date
    Jan 2018
    Location
    France
    Age
    71
    Posts
    69
    Rep Power
    13
    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.

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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