tcp-listener: fallback to polling instead of crashing on socket errors

This commit is contained in:
Jan Funke 2011-10-03 14:39:26 +02:00
parent 1a91c6d9c2
commit 73d11e0f9d

View file

@ -113,6 +113,8 @@ namespace SparkleLib {
} catch (SocketException e) {
SparkleHelpers.DebugInfo ("ListenerTcp", "Could not connect to " + Server + ": " + e.Message);
OnDisconnected ();
}
})
);
@ -132,8 +134,14 @@ namespace SparkleLib {
string to_send = "subscribe " + folder_identifier + "\n";
lock (this.mutex) {
this.socket.Send (Encoding.UTF8.GetBytes (to_send));
try {
lock (this.mutex) {
this.socket.Send (Encoding.UTF8.GetBytes (to_send));
}
} catch (SocketException e) {
SparkleHelpers.DebugInfo ("ListenerTcp", "Could not connect to " + Server + ": " + e.Message);
OnDisconnected ();
}
}
}
@ -145,8 +153,15 @@ namespace SparkleLib {
string to_send = "announce " + announcement.FolderIdentifier
+ " " + announcement.Message + "\n";
lock (this.mutex) {
this.socket.Send (Encoding.UTF8.GetBytes (to_send));
try {
lock (this.mutex) {
this.socket.Send (Encoding.UTF8.GetBytes (to_send));
}
} catch (SocketException e) {
SparkleHelpers.DebugInfo ("ListenerTcp", "Could not connect to " + Server + ": " + e.Message);
OnDisconnected ();
}
}