Re: NSInputStream get NSStreamEventEndEncountered without reason
Re: NSInputStream get NSStreamEventEndEncountered without reason
- Subject: Re: NSInputStream get NSStreamEventEndEncountered without reason
- From: Jens Alfke <email@hidden>
- Date: Mon, 06 May 2013 13:47:38 -0700
On May 4, 2013, at 1:44 PM, Kévin Vavelin <email@hidden> wrote:
> I use SocketIO project on my iOS app to connect to my node.js server and everything works great until I choose to connect to Facebook.
Using what protocol? I'm assuming HTTP. If so, then I would first suggest that you stop using a low-level stream API, and use NSURLConnection (or at least CFReadStreamCreateForHTTPRequest) instead. It will make your job so much easier. There are a couple of situations where you might want to use raw streams, but they're rather obscure.
> When I connect to Facebook I send some data to my server and he answer with some data like "user already connected, user created in database" etc. And after that, my NSInputStream seems to be at 0 and so my connexion is closed.
If it's HTTP, that's perfectly valid behavior. HTTP 1.0 uses a separate TCP connection for every request, so after the response is sent the socket is closed. HTTP 1.1 supports multiple connections over the same socket, but the client has to indicate that it supports that. (IIRC it depends on what HTTP version string you use in the first line of the request.)
—Jens
_______________________________________________
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