Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4741 → Rev 4740

/branches/network/uspace/srv/net/app/echo/echo.c
85,9 → 85,6
"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" \
142,7 → 139,6
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 ];
166,8 → 162,6
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 ));
188,9 → 182,7
break;
case 'v': verbose = 1;
break;
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 ){
case '-': 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 ));
271,11 → 263,7
}
 
if( type == SOCK_STREAM ){
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 ))){
if( ERROR_OCCURRED( listen( listening_id, 3 ))){
socket_print_error( stderr, ERROR_CODE, "Socket listen: ", "\n" );
return ERROR_CODE;
}