Catch network exceptions
This commit is contained in:
@@ -135,6 +135,7 @@ void serve( int host_fd )
|
|||||||
uint64_t last_remote_num = network.get_remote_state_num();
|
uint64_t last_remote_num = network.get_remote_state_num();
|
||||||
|
|
||||||
while ( 1 ) {
|
while ( 1 ) {
|
||||||
|
try {
|
||||||
int active_fds = poll( pollfds, 2, network.tick() );
|
int active_fds = poll( pollfds, 2, network.tick() );
|
||||||
if ( active_fds < 0 ) {
|
if ( active_fds < 0 ) {
|
||||||
perror( "poll" );
|
perror( "poll" );
|
||||||
@@ -205,5 +206,8 @@ void serve( int host_fd )
|
|||||||
& (POLLERR | POLLHUP | POLLNVAL) ) {
|
& (POLLERR | POLLHUP | POLLNVAL) ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} catch ( Network::NetworkException e ) {
|
||||||
|
fprintf( stderr, "%s: %s\r\n", e.function.c_str(), strerror( e.the_errno ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ void client( const char *ip, int port, const char *key )
|
|||||||
uint64_t last_remote_num = network.get_remote_state_num();
|
uint64_t last_remote_num = network.get_remote_state_num();
|
||||||
|
|
||||||
while ( 1 ) {
|
while ( 1 ) {
|
||||||
|
try {
|
||||||
int active_fds = poll( pollfds, 3, network.tick() );
|
int active_fds = poll( pollfds, 3, network.tick() );
|
||||||
if ( active_fds < 0 ) {
|
if ( active_fds < 0 ) {
|
||||||
perror( "poll" );
|
perror( "poll" );
|
||||||
@@ -204,5 +205,8 @@ void client( const char *ip, int port, const char *key )
|
|||||||
& (POLLERR | POLLHUP | POLLNVAL) ) {
|
& (POLLERR | POLLHUP | POLLNVAL) ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} catch ( Network::NetworkException e ) {
|
||||||
|
fprintf( stderr, "%s: %s\r\n", e.function.c_str(), strerror( e.the_errno ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user