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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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 09-23-2011, 03:57 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2011
Posts: 2
GuntherVB is on a distinguished road
Default CFSocket asynchronous communication

I'm trying to set up two-way communication between a server application and an iPhone application. What I've used is a CFSocket coupled to a CFReadStream which is itself scheduled with a run loop (or so it should be).

Thus I expect to have my callback function called for every event that I've registered for. But the only event I get is the "open completed" event, I don't even get an "end encountered" event when I close the socket.

WireShark shows the connection being established in a proper fashion. Data is also being PSH'ed and ACK'ed properly. The connection is FIN/ACK'ed properly when i kill the iPhone application. So everything looks fine. Netstat also shows an established connection, but netstat also shows the receive queue which i can see growing larger whenever i send data from the server to the iPhone application. However, no events are fired on the iPhone to signal that data is available.

I am clueless as to why I don't receive all events.

Here is the code (which is called from an UIViewController's viewDidLoad event):

[Objective C] CFSocket troubleshooting - Pastebin.com
GuntherVB is offline   Reply With Quote
Old 09-23-2011, 04:11 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2011
Posts: 2
GuntherVB is on a distinguished road
Default

As a sidenote: packets sent from the server to the client are only 7 bytes in size, so these are small packets. But even filling the receive queue with more than 4096 bytes does not trigger a receive event.

I've also read that callbacks are reenabled by default, so I didn't add this explicitly.
GuntherVB is offline   Reply With Quote
Old 09-23-2011, 12:00 PM   #3 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 97
Bopols is on a distinguished road
Default

Save yourself a lot of troubles and use AsyncSocket
It will take care of a lot of low level stuff for you. cocoaasyncsocket - AsyncSocket is an asynchronous socket networking library for Cocoa. - Google Project Hosting
Bopols is offline   Reply With Quote
Reply

Bookmarks

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: 390
14 members and 376 guests
7twenty7, eski, EvilElf, glenn_sayers, HemiMG, iOS.Lover, jarv, n00b, pbart, Pudding, sacha1996, Sami Gh, UMAD, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,905
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

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