pierrickrouxel / ssdpclient Goto Github PK
View Code? Open in Web Editor NEWSSDP client for Swift
License: MIT License
SSDP client for Swift
License: MIT License
The Package could not be resolved in SPM of current Xcode 12.5 (until 12.4 it works!):
"the Swift tools version specification is missing a label; consider inserting 'swift-tools-version:' between the comment marker and the version specifier"
Until my project is relying on your nice helper client, I would like to ask if you can fix this or if you can give me advice on how to fix it myself?
Thanks in advance,
Dan
It works fine on Simulator, but not work on a real watchOS device. I tested on watchOS 6.1.2. It shows error: "Error code: -9980(0x-26FC), No route to host"
Dear @pierrickrouxel !
Thank you for this nice piece of work.
I am currently testing your code and it looks like it only returns the first device which matches the "searchTarget". Is this how it is designed?
Any idea how I could improve it to return all devices which match the "searchTarget"?
Oliver
When this function is called readResponses() it gives me an error
Error code: -9982(0x-26FE), Bad file descriptor
domain : "com.ibm.oss.Socket.ErrorDomain"
errorCode : -9982
▿ errorReason : Optional
bufferSizeNeeded : 0
private func readResponses() {
do {
var data = Data()
let (bytesRead, address) = try self.socket!.readDatagram(into: &data)
if bytesRead > 0 {
let response = String(data: data, encoding: .utf8)
let (remoteHost, _) = Socket.hostnameAndPort(from: address!)!
Log.debug("Received: \(response!) from \(remoteHost)")
self.delegate?.ssdpDiscovery(self, didDiscoverService: SSDPService(host: remoteHost, response: response!))
}
} catch let error {
Log.error("Socket error: \(error)")
self.forceStop()
self.delegate?.ssdpDiscovery(self, didFinishWithError: error)
}
}
I've published an open source SSDP Browser based on this code, and including the improvements from my pull request #18.
Below are the logs
Started
[2022-09-17T15:26:27.279+05:30] [ERROR] [SSDPDiscovery.swift:132 discoverService(forDuration:searchTarget:port:)] Socket error: Error code: -9980(0x-26FC), No route to host
Error code: -9980(0x-26FC), No route to host
[2022-09-17T15:26:27.279+05:30] [ERROR] [SSDPDiscovery.swift:75 readResponses()] Socket error: Error code: -9982(0x-26FE), Bad file descriptor
Error code: -9982(0x-26FE), Bad file descriptor
Production is down due to this:
Added on Apple Thread:
https://developer.apple.com/forums/thread/715002
Can u please help:
@pierrickrouxel @kjpolaszek @cristianomatte @okankocyigit
I am getting a "initializer is inaccessible due to internal protection level" when I try to use the same code that you have in the tests (Swift4). What am I missing?
I have my Mac configured to use two network interfaces on two subnets.
When I use discoverService()
, it will only get responses on the default interface.
The solution is to listen on all local interfaces. This is accomplished by using multiple sockets for every interface, and passing each interface's local IP address via the node:
parameter to the listen()
function.
That much I have already verified to work. The remaining challenge is to get all interfaces. I am working on that and will then offer a merge request.
Hi there
when using the library and running it on my macOS (m1) simulator (iOS 14.1) it runs ok and finds the services on my network.
but when running It on a real device, iPhone 8 iOS version 14.6, I always get a socket error: No route to host
any idea why and how to solve it? thanks
Hi,
When using SSDPClient the Location I get back contains only the service's IP and not its port. Is there a way to get it?
Thanks!
This does not work anymore on iOS16 devices (but works on simulator).
Got this error : Encountered socket error:
The operation couldn’t be completed.
[2023-05-31T14:45:42.421+07:00] [ERROR] [SSDPDiscovery.swift:132 discoverService(forDuration:searchTarget:port:)] Socket error: Error code: -9980(0x-26FC), No route to host
----> Error code: -9980(0x-26FC), No route to host
[2023-05-31T14:45:42.421+07:00] [ERROR] [SSDPDiscovery.swift:75 readResponses()] Socket error: Error code: -9982(0x-26FE), Bad file descriptor
----> Error code: -9982(0x-26FE), Bad file descriptor
Any ideas
Response:
"HTTP/1.1 200 OK\r\nCache-Control: max-age=1800\r\nDate: Thu, 06 Jun 2024 11:01:02 GMT\r\nST: upnp:rootdevice\r\nEXT: \r\nSERVER: Platform 1.0 His/1.0 UPnP/1.0 DLNADOC/1.50\r\nUSN: uuid:898e0775-23f2-11ef-8b3d-84ba39bb8fb2::upnp:rootdevice\r\nLocation: http://192.168.1.59:38400/MediaServer/rendererdevicedesc.xml\r\n\r\n"
Parsed location:
"http://192.168.1.59:38400/MediaServer/rendererdevicedes"
Correct location:
"http://192.168.1.59:38400/MediaServer/rendererdevicedesc.xml"
Could you please fix that and submit new release? You can do that by replacing "let matches = HeaderRegex.matches(in: response, range: NSRange(location: 0, length: response.count))" with "let matches = HeaderRegex.matches(in: response, range: NSRange(location: 0, length: response.utf16.count))"
Thank you a lot
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.