Ok, after re-writing my network code/socket handling code completely, using raw sockets with the new event based Async approach (SendAsync, ReceiveAsync, SocketAsyncEventArgs etc...), testing extensively on test PC/Windows apps then moving to my app this problem is STILL happening!
So I moved the network code to a test iOS app, and the problem disappeared. Im now pretty sure the problem is to do with the Threadpool. As the Async events from the sockets call back in a new Threadpool thread, I guess they are stuck waiting for a free thread. WHen one becomes available, its used to receive the data, which my app quickly processes and the same thread is used again and again to get the remaining data. This would explain why suddenly all the receives come in one after each other. Ive tried increasing the thread count, but it still happens now and then. Is there a hard limit on the thread count that is limited, regardless of whats set in ThreadPool.SetMaxThreads()? Does the internal processes in code such as the Socket.ReceiveAsync() etc.. comsume threadpool threads? Also, is there any easy way to keep an eye on my thread count other than the thread window in monotouch? I seem to have about 13 threads running when the problem occurs. A lot of them have no current location though, so I dont know where they are or what they're doing. Any help appreciated! Thanks. -- View this message in context: http://monotouch.2284126.n4.nabble.com/Serious-strange-problems-with-Sockets-TcpClient-tp4595780p4605780.html Sent from the MonoTouch mailing list archive at Nabble.com. _______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
