 |
 |
|
 |
07-10-2009, 09:47 AM
|
#1 (permalink)
|
|
Registered Member
Join Date: Jul 2009
Posts: 22
|
Network Programming on iPhone
Hi there!
I'm trying to implement an iPhone Client which is communicating with a Java Server via TCP and/or UDP.
It seems that there are a couple of options how to do that and i'm a little bit confused right now. I'm also new to this Objective-C stuff but trying to get used to it.
I read that UNIX Sockets are available. I have to write C-Code for that right? Can i just write the C-Code into my ObjC implementation or how should i do that? Isn't that ugly? Or can i somehow write a C coded file and implement the stuff into an ObjC class?
Additionally i found out that i may use CFNetwork. But i can't find a good resource which tells me how to do that. Do i have to create a CFSocket first and then create the read/write streams for that?
After that i saw NSStreams should be also an option.
I'm a bit confused and don't know which technology to choose and how to implement the whole thing. I "just" need to add network functionality to an existing iPhone Application to transmit data. The best thing would be a class that i can instanciate (giving it a host, port, calling a connect function ...) and use it to send data.
What would you recommend? Do you have any hints or examples for me? That would be very great.
Thanks in advance,
kiwaque
|
|
|
07-10-2009, 12:08 PM
|
#2 (permalink)
|
|
Registered Member
Join Date: Apr 2009
Posts: 78
|
why don't just use good old plain C (there are a lot of examples on BSD sockets) and don't bother about "ugliness"? %)
__________________
iPhone 2G 8Gb 3.1.2 JB, 3G 16Gb 3.1.2 JB, 3GS 16 Gb 3.1.2 JB
MB5,1 C2D 2GHz 2GB RAM
Mac OS X 10.5.8
|
|
|
07-11-2009, 03:31 AM
|
#3 (permalink)
|
|
Registered Member
Join Date: Jul 2009
Posts: 22
|
Because this is for university and i have to figure out a clean solution
|
|
|
07-11-2009, 03:41 AM
|
#4 (permalink)
|
|
Registered Member
Join Date: Jun 2008
Location: Planet Earth
Posts: 415
|
To make things easier, better to use combinations of NSStream and CFSocket and its related family.
Check "CocoaEcho" sample code in Apple's developer website.
I've been there with BSD socket, and it's a pain to do asynchronous behavior.
For UDP, you might just have to modify the socket type somewhere, or you could create an Objective-C wrapper out of BSD socket, and integrate with the existing TCP solution.
The WiTap on iPhone is also an example.
__________________
Visit Me
Writing code is not only about writing instructions to a machine / computer, but also about writing something that could be read, understood, and maintained by others. That's why, I like Cocoa.
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 423 |
| 44 members and 379 guests |
| AgCode, amit.wizkid, appie, applegun, bbc z, chrisho_pro, Corey, develsolutions, eieiosoftware, firearasi, gbaldwin9, goodcode, harrytheshark, HemiMG, iGeorG, Issue, ivanovich, jbro, JefRH1, Kalimba, KarlG, KennyChong, kiancheong, kjhh15, Lane, libertas, marciokoko, MiniRobinho, moe, MrMattMac, natekruser, odysseus31173, PhotoShootoutApp, rawjam, redon, refreshe, schoash, Smudeli, svveet, trump-card, wassupdoc, xellosss, ZunePod |
| Most users ever online was 779, 05-11-2009 at 09:55 AM. |
» Stats |
Members: 24,296
Threads: 39,086
Posts: 171,382
Top Poster: smasher (2,575)
|
| Welcome to our newest member, Issue |
|