It is currently Tue Sep 25, 2018 6:04 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 
Offline
Enthusiast
Enthusiast

Joined: Fri Jul 14, 2006 8:53 pm
Posts: 630
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

Code:
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)
      EndIf
      DnsRecordListFree(*Record, #DnsFreeRecordList)
    EndIf
  EndIf
 
  ProcedureReturn Name$ 
EndProcedure


Under linux

Code:
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 )
                  EndIf
                 
               EndIf
            Wend
         
            CloseProgram( pid ) ; Close the connection to the program 
         EndIf


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

_________________
Brazil, wait for me, here I come...

http://www.en3.biz


Top
 Profile  
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 7 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