French Comment scanner Les IP locales

Riketude

New Member
Licensed User
Longtime User
Bonjour à tous
Quelqu'un sait il comment faire un scan du reseau local ?
Merci
 

scrat

Active Member
Licensed User
Longtime User
Sinon y' a ça mais c'est pas rapide.

B4X:
Sub RunPing
Dim Command As String
Dim Result As Int
Dim Ph As Phone
Dim Adr As String
Dim Start As Int
Dim stop As Int
Dim M As Int

Command = File.Combine(File.DirInternalCache, "command")
Adr="192.168.1."
Start=1
stop=254
For M=Start To stop
File.WriteString(File.DirInternalCache, "command", "ping -w 1 -c 1 -n " & Adr & M  & CRLF & "exit")
Dim StdOut, StdErr As StringBuilder
StdOut.Initialize
StdErr.Initialize
Result = Ph.Shell("sh", Array As String(Command), StdOut, StdErr)
Dim R As String
R=StdOut.ToString
If R.Contains("1 received") Then
Log(Adr & M & " On")
Else
Log(Adr & M & " Off")
End If
Next
End Sub
 

dobro

Member
Licensed User
@a_carignan


ce code marche tres bien !!

cependant il faut deja le lancer sur un vrais peripherique (pas l'emulateur )
et surtout , mettre le mode Debug dans les modes de compilation !!

l'emploi de Log() oblige a ça, si tu veux voir quelque chose (dans le log de l'editeur) , en lançant le code sur un vrais peripherique ...

Merci Scrat , tres bon code ;)
 
Last edited:
Top