Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-10-2009, 10:47 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 22
Angry 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
kiwaque is offline   Reply With Quote
Old 07-10-2009, 01:08 PM   #2 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 81
Default

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
Jeepston is offline   Reply With Quote
Old 07-11-2009, 04:31 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 22
Default

Because this is for university and i have to figure out a clean solution
kiwaque is offline   Reply With Quote
Old 07-11-2009, 04:41 AM   #4 (permalink)
Registered Member
 
mnemonic_fx's Avatar
 
Join Date: Jun 2008
Posts: 419
Default

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.
mnemonic_fx is offline   Reply With Quote
Reply

Bookmarks

Tags
networking

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 924
14 members and 910 guests
Abb4ertW, cacao, Desert Diva, Diegan, glennrichard113, ios dev, klbaiju, leahov, mizzytheboy, nguyenhieu129, Ocguy, pinky, qkstrk, Snail
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,298
Threads: 89,032
Posts: 379,810
Top Poster: BrianSlick (7,086)
Welcome to our newest member, glennrichard113
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:19 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0