I ran into something similar in my application a while back. I made two changes to work around it: 1. Close the socket outside of any locked mutexes. We were already in a separate thread for each socket so if that thread hangs for a while we can tolerate it so long as it doesn't block other threads. 2. Added a call to Shutdown before Close. You said you already tried this, but I noticed that we also pass in SocketShutdown.Both as an argument to Shutdown. I think that was important. Have you tried that? -- Adam Kemp [email protected] (512) 683-6058
[email protected] wrote on 08/01/2012 02:45:37 AM: > From: "Alexandr Němec" <[email protected]> > To: <[email protected]> > Date: 08/01/2012 02:45 AM > Subject: [MonoTouch] socket.Close() problem > Sent by: [email protected] > > Dear all, > > we are using MonoTouch 3.0.3.4 and we have discovered a problem with > the socket class. Our application uses TCP sockets and we found out > that occasionally upon socket closure (after some data has been sent > and received) the application hangs in socket.Close() method. We do > not use any linger interval, so there should be absolutely no reason > for the socket.Close method to wait for anything. This happens with > and also without calling Shutdown before Close. > > From what we saw in the Assembly Browser, Close calls socket.Dispose > which calls some other methods like Linger etc. which might be the > cause for the Close call to block. > > Is this a bug or is there a way / workaround to make an > abortive socket close without any waits? > > Also, from what we have seen in the socket.Dispose method, the Close > method might end up with an exception, but AFAIK there is no > exception documented for the socket.Close method in .NET. This might > be dangerous when you do not expect any exception here. > > Thanks for any suggestions. > > Alex > > _______________________________________________ > MonoTouch mailing list > [email protected] > http://lists.ximian.com/mailman/listinfo/monotouch _______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
