tcp - iPhone/iPod receive messages from C# tcpip server using CocoaAsyncSocket -
I am trying to send / receive data from a C # TCPIP server to WiFi on iPhone / iPod Touch app on iPhone / iPod Touch. For this, I used cocosyncascats from Google Project. If I press a button and I send a request from the iPod to the server then it returns the requested data (for example the title of the song) .. I want to know every second what song is plagiarized ... then Send C # server at intervals of 1 The second message of my app reads asyncSocket in my app in a timer with a interval of 1 second, read DataAwitTimeout method. My problem is that after 8-9 seconds the method is no longer called. The connection to the server is still active and the C # server still sends the data.
What do I want to do: -> Winamp runs a song -> C # server asks if the song is Plays the song title for my app and sends -> The iPhone app receives the data and displays it
I do not know why the readDataWithTimeout method is not called after a short period of time Probably because C # sent by the server Less time between messages gone?
Thanks, Sorin
There are many things here. First of all, why does it do each other instead of just singing? It can be very expensive on the iPhone's battery so that it can continuously talk like this. There is very little reason to do this on the desktop too.
So if I understand correctly, then connects to the iPhone .net and asks for the song. Gives the .NET song and opens the socket. Every other, .net writes in its socket, and every other iPhone reads from its socket.
What I am suspecting is that readDataWithTimeout: tag: does not expire before the next NSTimer fire (at any point about it) The actual guarantee is when it will set fire). You might then be able to call two readDataWithTimeout: tag: calls running at the same time, maybe the fault representative is confused.
A better solution is a "long election". On the iPhone side, call readDataWithTimeout: Tags: with a fairly long time (says 30-60s). Every time it comes back, just loop it back in:
while (self.isRunning) {[socket readadata with timetime: 60 tags: 0]; } then -onSocketDidDisconnect: and -onSocket: willDisconnectWithError: , be sure to set self.isRunning code> from not NSTimer.
Until Winamp actually changes the song, I do not post anything from the .NET side. The same data is being sent repeatedly, no one favors.
Comments
Post a Comment