Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4740 → Rev 4741

/branches/network/uspace/srv/net/app/echo/echo.c
85,6 → 85,9
"Network Echo aplication\n" \
"Usage: echo [options]\n" \
"Where options are:\n" \
"-b backlog | --backlog=size\n" \
"\tThe size of the accepted sockets queue. Only for SOCK_STREAM. The default is 3.\n" \
"\n" \
"-c count | --count=count\n" \
"\tThe number of received messages to handle. A negative number means infinity. The default is infinity.\n" \
"\n" \
139,6 → 142,7
int count = -1;
int family = PF_INET;
uint16_t port = 7;
int backlog = 3;
 
socklen_t max_length = sizeof( struct sockaddr_in6 );
uint8_t address_data[ max_length ];
162,6 → 166,8
for( index = 1; index < argc; ++ index ){
if( argv[ index ][ 0 ] == '-' ){
switch( argv[ index ][ 1 ] ){
case 'b': ERROR_PROPAGATE( parse_parameter_int( argc, argv, & index, & backlog, "accepted sockets queue size", 0 ));
break;
case 'c': ERROR_PROPAGATE( parse_parameter_int( argc, argv, & index, & count, "message count", 0 ));
break;
case 'f': ERROR_PROPAGATE( parse_parameter_name_int( argc, argv, & index, & family, "protocol family", 0, parse_protocol_family ));
182,7 → 188,9
break;
case 'v': verbose = 1;
break;
case '-': if( str_lcmp( argv[ index ] + 2, "count=", 6 ) == 0 ){
case '-': if( str_lcmp( argv[ index ] + 2, "backlog=", 6 ) == 0 ){
ERROR_PROPAGATE( parse_parameter_int( argc, argv, & index, & backlog, "accepted sockets queue size", 8 ));
}else if( str_lcmp( argv[ index ] + 2, "count=", 6 ) == 0 ){
ERROR_PROPAGATE( parse_parameter_int( argc, argv, & index, & count, "message count", 8 ));
}else if( str_lcmp( argv[ index ] + 2, "family=", 7 ) == 0 ){
ERROR_PROPAGATE( parse_parameter_name_int( argc, argv, & index, & family, "protocol family", 9, parse_protocol_family ));
263,7 → 271,11
}
 
if( type == SOCK_STREAM ){
if( ERROR_OCCURRED( listen( listening_id, 3 ))){
if( backlog <= 0 ){
fprintf( stderr, "Accepted sockets queue size too small (%d). Using 3 instead.\n", size );
backlog = 3;
}
if( ERROR_OCCURRED( listen( listening_id, backlog ))){
socket_print_error( stderr, ERROR_CODE, "Socket listen: ", "\n" );
return ERROR_CODE;
}