RE: BSD TCP Programming on iPad
RE: BSD TCP Programming on iPad
- Subject: RE: BSD TCP Programming on iPad
- From: Shawn Bakhtiar <email@hidden>
- Date: Wed, 27 Apr 2011 14:10:50 -0400
- Importance: Normal
I think your statement "I cannot make a decision which technique I should use," says it all.
The problem is your looking at this from the prospective of a script writer, not a programmer with at least three possible options (NSStream, BSD socks, etc), of which YOU need to choose which is best. The list has given you quite a few choices, and everyone has chimed in on their preferences. You are use to having one way of having it done, most likely with plenty of cookie cut code to go with it.
Personally, I write as much of my code in C, and only use objective-C when I have too. this keeps the base as portable as possible. Frankly you could even write your one low-level io if you really like pain. This depends on many factors:
1) Number of transactions
2) size of each transaction
3) Number of persistent connection
4) Do you need RTSP for time sensitivity
5) Do you need custom packets
6) etc....
> Date: Thu, 28 Apr 2011 01:49:31 +0800
> From: email@hidden
> To: email@hidden
> CC: email@hidden
> Subject: Re: BSD TCP Programming on iPad
>
> 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 <
> email@hidden> 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 (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