Re: NSURLSession + Bonjour to do peer-to-peer file transfers?
Re: NSURLSession + Bonjour to do peer-to-peer file transfers?
- Subject: Re: NSURLSession + Bonjour to do peer-to-peer file transfers?
- From: "Stephen J. Butler" <email@hidden>
- Date: Wed, 25 Dec 2013 11:15:18 -0600
NSURLSession is a fancy HTTP client. It needs to talk to an HTTP server.
None of the included iOS and OS X frameworks (that I'm aware of) include an
HTTP server.
You can either run an HTTP server on the device in your app (
https://www.google.com/search?q=ios+http+server) or you can write your own
protocol and implement it.
On Wed, Dec 25, 2013 at 9:26 AM, Eric Wing <email@hidden> wrote:
> Is it possible to use NSURLSession + Bonjour to do peer-to-peer like
> file transfers? My example situation is that I have a Mac and iPhone.
> The iPhone has a generated file I want to copy over to the Mac through
> the wireless.
>
> I can publish my iPhone via Bonjour and make my Mac discover and
> resolve the address. I try to create a NSURLSessionDownloadTask on my
> Mac and a NSURLSessionUploadTask on my iPhone.
>
> My DownloadSession (from Mac) connects to the advertised Bonjour
> service (iPhone). But when I create the UploadSession (iPhone), I get
> a NSErrorFailingURLStringKey.
>
>
> Networks are not my strong suit, so I really don’t know if I'm on the
> right path. (On the iPhone, I picked a random socket to advertise on.
> When I resolve it on my Mac and create the DownloadSession, it
> connects on that same port which triggers the iPhone to create an
> UploadSession. I originally tried using getpeername to reuse the same
> port, but also tried hardcoding a free port that both could connect
> to. Neither seemed to help.) I’m also a bit confused on how to convert
> NSNetService to NSURLs which can be fed to NSURLRequests for
> NSURLSessions. (I basically take the NSNetService hostName and port
> properties and generate a string of the form:
> "http://hostName:port/").
>
>
> My eventual goal is to make this work with non-Apple devices too, e.g.
> a Mac pulls from an Android device instead of iPhone. So I was looking
> at NSURLSession because I assumed it used a standard protocol that
> would be easy to talk with on other platforms.
>
> Thanks,
> Eric
> --
> Beginning iPhone Games Development
> http://playcontrol.net/iphonegamebook/
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden