It is currently Wed Oct 21, 2020 1:37 pm

All times are UTC + 1 hour

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: DNS Resolve
PostPosted: Sat Jan 20, 2018 10:51 am 

Joined: Fri Jul 14, 2006 8:53 pm
Posts: 694
Location: Malta
Hello Guys,

I have recently started coding under linux and have ported some tools with very little difficulty; except now I am stuck on DNS
Under windows I can resolve with API

Procedure.s ReverseDnsQuery(IP.i)
  Protected Name$ = "", *Record.DNS_RECORD
  Protected Query$ = Str((IP>>24) & $FF)+"."+Str((IP>>16) & $FF)+"."+Str((IP>>8) & $FF)+"."+Str(IP & $FF)+".IN-ADDR.ARPA" ; ip must be reversed!
  If DnsQuery_W And DnsRecordListFree
    If DnsQuery_W(Query$, #DNS_TYPE_PTR, #DNS_QUERY_STANDARD, #Null, @*Record.DNS_RECORD, #Null) = 0 And *Record
      If *Record\wType = #DNS_TYPE_PTR
        Name$ = PeekS(*Record\PTR\pNameHost, -1, #PB_Unicode)
      DnsRecordListFree(*Record, #DnsFreeRecordList)
  ProcedureReturn Name$ 

Under linux

pid      = RunProgram( "dig", "-x " + ip + " +short +tries=1 +time=" + Trim( Str( gDNSWait ) ), "", #PB_Program_Open | #PB_Program_Read )
         output   = ""
         If pid
            While ProgramRunning( pid )
               If AvailableProgramOutput( pid )
                  temp = ReadProgramString( pid )
                  j = CountString( temp, "." )
                  If j > max
                     max = j
                     output = Left(temp, Len(temp) - 1 )
            CloseProgram( pid ) ; Close the connection to the program 

The difference is extraordinary - windows less than 1 second, under linux from 38 to 71 seconds!
Can someone help?

I may not help with your coding
Just ask about mental issues!

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour

Who is online

Users browsing this forum: No registered users and 5 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye