File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ private void ServerControl()
102102 if ( _threadServer == null )
103103 {
104104 _server = new Server ( _parser ) ;
105+ _server . ServerError += OnServerError ;
105106 _threadServer = new Thread ( new ThreadStart ( _server . Start ) ) ;
106107 _threadServer . Start ( ) ;
107108 }
@@ -156,5 +157,11 @@ private void OnSerialError(object sender, EventArgs e)
156157 _threadSerial = null ;
157158 checkSerial . Checked = false ;
158159 }
160+
161+ private void OnServerError ( object sender , EventArgs e )
162+ {
163+ _threadServer = null ;
164+ checkNetwork . Checked = false ;
165+ }
159166 }
160167}
Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ namespace SDRSharp.NetRemote
4242
4343 class Server
4444 {
45+ public event EventHandler ServerError ;
46+
4547 private const int PORT = 3382 ;
4648 private const int MAX_CLIENTS = 4 ;
4749
@@ -86,10 +88,13 @@ public void Start()
8688 }
8789 catch ( SocketException ex )
8890 {
91+ OnServerError ( ) ;
92+
8993 if ( socket . IsBound )
9094 socket . Shutdown ( SocketShutdown . Both ) ;
9195
92- MessageBox . Show ( ex . Message , Info . Title ( ) ,
96+ string msg = "Network Error:\n " + ex . Message ;
97+ MessageBox . Show ( msg , Info . Title ( ) ,
9398 MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
9499 }
95100 finally
@@ -251,6 +256,15 @@ private void OnTimerAlive(object source, ElapsedEventArgs e)
251256 ClientRemove ( client ) ;
252257 }
253258 }
259+
260+ protected virtual void OnServerError ( )
261+ {
262+ EventHandler handler = ServerError ;
263+ if ( handler != null )
264+ {
265+ handler ( this , EventArgs . Empty ) ;
266+ }
267+ }
254268 }
255269
256270
You can’t perform that action at this time.
0 commit comments