Dear Conrad and all, I appreciate so much for all of your replies!
Since I am a new iOS developer, I cannot make a decision which technique I should use. Now I just clarify my system again. What I am trying to do is to implement a BitTorrent-like multicast among iPad. Meanwhile, the original data is from a Java/Linux machine. I have ever done that successfully using C# on Windows and Java/Linux. However, when replacing C#/Windows with Cocoa/iOS, I got some difficulties. The iPad must behave as both a client and a server at the same time. When doing that using C# on Windows, I can manipulate sockets directly. I am not sure which technique is a proper choice. Since C sockets on Unix are look like C# sockets, I prefer using them. But I am not sure if the approach is the best one. Your suggestions are highly appreciated! Thanks so much! Bing On Thu, Apr 28, 2011 at 1:17 AM, Conrad Shultz < con...@synthetiqsolutions.com> wrote: > Bing Li wrote: > > I have a Java based server. So iPad needs to communicate with it. > > Moreover, I hope a P2P model can be established between the server and > > multiple iPads. Therefore, I hope I could use TCP to design the protocol > > directly instead of using HTTP. > > Since HTTP typically runs over TCP I assume your concern is not wanting > to implement an HTTP server in your app for the P2P functionality? > > If this is the case, I will first point out that there are actively > maintained open source HTTP daemons that I found by Googling (e.g. > http://code.google.com/p/cocoahttpserver/); can't vouch for their > quality, but seem to be widely referenced and used. > > It is worth pointing out, with respect to your previous post, that the > fact that your servers run Java or the fact that you think XML might be > a good file format are not relevant to your decision about lower level > network architecture. > > > However, I have NOT got sufficient materials to program TCP on iPad. > > Should you decide not to go with NSURLConnection, etc., I would think > you should be able to fall back to using NSStream and its siblings > before needing to drop all the way down into the CFNetwork layer (which, > as others have pointed out, will certainly do what you need without > resorting to BSD sockets) for everything. > > The one subtle complication here is that NSStream does not currently > support remote connections on iOS without modification. Fortunately, > Apple provides documentation on how to get around this with a minimal > amount of CFNetwork to setup the stream: > > > http://developer.apple.com/library/ios/#DOCUMENTATION/Cocoa/Conceptual/Streams/Articles/NetworkStreams.html > http://developer.apple.com/library/ios/#qa/qa1652/_index.html > > This would then give you all the NSStream Objective-C goodness, which > comports with the principle of using the highest level constructs > available that meet all your needs. > > (Personally, I would spend a modest amount of time seeing whether I > could use HTTP, thereby removing the network stream code entirely. But > NSStream isn't too much of a burden if HTTP is unworkable for license, > performance, or other reasons.) > > -- > Conrad Shultz > > Synthetiq Solutions > www.synthetiqsolutions.com > twitter.com/TechConrad > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com