Reputation: 9636
I want to find Mac and IP addresses of all the devices connected to the local network in Swift. I looked into AFNetworking/Alamofire, but it does not seem have the functionality I want. So, which API or Library I can use?
Upvotes: 2
Views: 9611
Reputation: 61
You can try to type "arp -a" in your Terminal, or use this in swift
let theOutput = Pipe()
func shell(Path:String ,args: String...) -> Int32 {
let task = Process()
task.launchPath = Path
task.arguments = args
task.standardOutput = theOutput
task.standardError = theOutput
task.launch()
task.waitUntilExit()
return task.terminationStatus
}
shell(Path:"/usr/sbin/arp",args: "-a")
let theTaskData = theOutput.fileHandleForReading.readDataToEndOfFile()
let stringResult = String(data: theTaskData, encoding: .utf8)
print(stringResult!)
Upvotes: 0
Reputation: 21
AFNetworking and Alamofire "only" handle requests. But as i understood you want to scan the local network for devices.
A quick Google search brought me to this: https://stackoverflow.com/a/21992359/2753395
Upvotes: 2