tcp-listener: fallback to polling instead of crashing on socket errors
This commit is contained in:
parent
1a91c6d9c2
commit
73d11e0f9d
|
@ -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 ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue