Catch network exceptions

This commit is contained in:
Keith Winstein
2011-08-14 03:32:04 -04:00
parent e50b67b845
commit 827d95f6fd
2 changed files with 118 additions and 110 deletions
+4
View File
@@ -135,6 +135,7 @@ void serve( int host_fd )
uint64_t last_remote_num = network.get_remote_state_num();
while ( 1 ) {
try {
int active_fds = poll( pollfds, 2, network.tick() );
if ( active_fds < 0 ) {
perror( "poll" );
@@ -205,5 +206,8 @@ void serve( int host_fd )
& (POLLERR | POLLHUP | POLLNVAL) ) {
break;
}
} catch ( Network::NetworkException e ) {
fprintf( stderr, "%s: %s\r\n", e.function.c_str(), strerror( e.the_errno ) );
}
}
}
+4
View File
@@ -139,6 +139,7 @@ void client( const char *ip, int port, const char *key )
uint64_t last_remote_num = network.get_remote_state_num();
while ( 1 ) {
try {
int active_fds = poll( pollfds, 3, network.tick() );
if ( active_fds < 0 ) {
perror( "poll" );
@@ -204,5 +205,8 @@ void client( const char *ip, int port, const char *key )
& (POLLERR | POLLHUP | POLLNVAL) ) {
break;
}
} catch ( Network::NetworkException e ) {
fprintf( stderr, "%s: %s\r\n", e.function.c_str(), strerror( e.the_errno ) );
}
}
}