Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Isorinu'

macrumors newbie
Original poster
Oct 16, 2008
19
0
Hello,
i'm writing a little app for iphone that needs to comunicate over TCP/IP with a C# server. My iphone app is working..it can send and receive data from the C# server after connecting to it(for that i am using the AsyncSocket class from google code project), the C# server also can send and receive data from/to the iphone app.

my problem is when the iphone app receives a message from the server it can't display it right away. for example i have a UILabel serverMessage. If i read the data from the socket and i say serverMessage.Text = (data from the socket) it will not show the message sent... but if i reload the view the data send from the server it will be available...

this problem that i have does not resume only in the case when i want to show the data sent by the server but also when i try to access it after reading it from the socket.

any ideas? i found on another site a similar problem but they resolved it by making another thread for listening on the port.. also they used notifications..when something was received the views registered to receive notification would act..

it sounded like a very good idea..but when i hear about threading i'm a little in the dark...

thank you in advance
 
Does AsyncSocket use a secondary thread to achieve it's async behaviour? If so try updating your UI on the main thread as updates from other threads don't work.
 
Hello Robbie,

The AsyncSocket class(link) is Run-loop based, not thread based. On google code it says that it can be used on main or worker threads, but it doesn't have to. It calls the delegate methods asynchronously using NSRunLoop. The delegate methods include a socket parameter, allowing you to distinguish between many instances.
 
You can't update the UI from a background thread. You can use performSelectorOnMainThread from a background thread and update the UI from that call.
 
Help iPhone <---> Windows Communication

Hey,
I am trying to connect iPhone and Windows.. Having some problem with the same for coding stuff for the client(iPhone)
Please help by sharing your accomplishment.
Thanks

Rahul
Hello,
i'm writing a little app for iphone that needs to comunicate over TCP/IP with a C# server. My iphone app is working..it can send and receive data from the C# server after connecting to it(for that i am using the AsyncSocket class from google code project), the C# server also can send and receive data from/to the iphone app.

my problem is when the iphone app receives a message from the server it can't display it right away. for example i have a UILabel serverMessage. If i read the data from the socket and i say serverMessage.Text = (data from the socket) it will not show the message sent... but if i reload the view the data send from the server it will be available...

this problem that i have does not resume only in the case when i want to show the data sent by the server but also when i try to access it after reading it from the socket.

any ideas? i found on another site a similar problem but they resolved it by making another thread for listening on the port.. also they used notifications..when something was received the views registered to receive notification would act..

it sounded like a very good idea..but when i hear about threading i'm a little in the dark...

thank you in advance
 
Source code of C# ASyncSocket

Hello,
i'm writing a little app for iphone that needs to comunicate over TCP/IP with a C# server. My iphone app is working..it can send and receive data from the C# server after connecting to it(for that i am using the AsyncSocket class from google code project), the C# server also can send and receive data from/to the iphone app.

my problem is when the iphone app receives a message from the server it can't display it right away. for example i have a UILabel serverMessage. If i read the data from the socket and i say serverMessage.Text = (data from the socket) it will not show the message sent... but if i reload the view the data send from the server it will be available...

this problem that i have does not resume only in the case when i want to show the data sent by the server but also when i try to access it after reading it from the socket.

any ideas? i found on another site a similar problem but they resolved it by making another thread for listening on the port.. also they used notifications..when something was received the views registered to receive notification would act..

it sounded like a very good idea..but when i hear about threading i'm a little in the dark...

thank you in advance

I have downloaded both the AsyncSocket code for iPhone and C# from http://code.google.com/p/cocoaasyncsocket/ & http://www.deusty.com/opensource/downloads/WinAsyncSocket.zip.
But I am not able to do a data transmission using these code between iPhone and C# server. I have a doubt whether i have the updated code for the C# server as it is mentioned it can be downloaded from Google code, but there is nothing on the http://code.google.com/p/dotnetasyncsocket/

Can you please let me know from where I can download the latest code? If you can help to send me sample working for both iPhone and C# server, that will be great.

Any help is really appreciated.

Thanks,
Susanta
 
Hi,

I am trying to do the same thing. iPhone as a client (CocoaAsyncSocket) and PC as a server (C#). Can anyone share their basic codes with me? Many many thanks.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.