Changeset 676 for trunk/user/tcp_server


Ignore:
Timestamp:
Nov 20, 2020, 12:11:35 AM (4 years ago)
Author:
alain
Message:

Introduce chat application to test the named pipes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/user/tcp_server/tcp_server.c

    r668 r676  
    4040        if( nbytes < 0 )
    4141        {
    42             printf("\n\n[server] receive error => return to main\n" );
     42            printf("\n\n[tcp_server error] cannot receive => return to main\n" );
    4343            return;
    4444        }
    4545        else if( nbytes == 0 )
    4646        {
    47             printf("\n\n[server] receive EOF => return to main\n" );
     47            printf("\n\n[tcp_server stop] received EOF => return to main\n" );
    4848            return;
    4949        }
     
    6161        if( strncmp( "exit" , buffer , 4 ) == 0 )
    6262        {
     63            printf("\n[tcp_server stop] local message is <exit> => return to main\n" );
    6364            return;
    6465        }
     
    6970        if( nbytes != size )
    7071        {
    71             printf("\n[server] send error => chat return to main\n" );
     72            printf("\n[tcp_server error] cannot send => return to main\n" );
    7273            return;
    7374        }
     
    9798    pid = getpid();
    9899
    99     printf("\n[server] starts at cycle %d\n",
     100    printf("\n[tcp_server] starts at cycle %d\n",
    100101    (unsigned int)start_cycle );
    101102
     
    107108    if( listen_fdid < 0 )
    108109    {
    109         printf("\n[server error] cannot create socket\n");
     110        printf("\n[tcp_server error] cannot create socket\n");
    110111        exit( 0 );
    111112    }
    112113    else
    113114    {
    114         printf("\n[server] created socket[%x,%d]\n", pid, listen_fdid );
     115        printf("\n[tcp_server] created socket[%x,%d]\n", pid, listen_fdid );
    115116    }
    116117
     
    125126    if( error )
    126127    {
    127         printf("\n[server error] bind failure for socket[%x,%d]\n",
     128        printf("\n[tcp_server error] bind failure for socket[%x,%d]\n",
    128129        pid, listen_fdid );
    129130        exit( 0 );
    130131    }
    131132
    132     printf("\n[server] listening socket[%x,%d] bound : [%x,%x]\n",
     133    printf("\n[tcp_server] listening socket[%x,%d] bound : [%x,%x]\n",
    133134    pid, listen_fdid, server_sin.sin_addr, server_sin.sin_port );
    134135
     
    138139    if( error )
    139140    {
    140         printf("\n[server error] listen failure for socket[%x,%d]\n",
     141        printf("\n[tcp_server error] listen failure for socket[%x,%d]\n",
    141142        pid, listen_fdid );
    142143        exit( 0 );
    143144    }
    144145
    145     printf("\n[server] listening socket[%x,%d] waiting connection request\n",
     146    printf("\n[tcp_server] listening socket[%x,%d] waiting connection request\n",
    146147    pid, listen_fdid );
    147148   
     
    153154    if( chat_fdid < 0 )
    154155    {
    155         printf("\n[server error] accept failure on socket[%x,%d]\n",
     156        printf("\n[tcp_server error] accept failure on socket[%x,%d]\n",
    156157        pid, listen_fdid );
    157158        exit( 0 );
    158159    }
    159160
    160     printf("\n[server] chat socket[%x,%d] accepted client [%x,%x]\n",
     161    printf("\n[tcp_server] chat socket[%x,%d] accepted client [%x,%x]\n",
    161162    pid, chat_fdid , client_sin.sin_addr , client_sin.sin_port );
    162163
     
    168169    close( listen_fdid );
    169170
    170     printf("\n[server] closed both <listen> & <chat> sockets\n" );
     171    printf("\n[tcp_server] closed both <listen> & <chat> sockets\n" );
    171172
    172173    exit(0);
Note: See TracChangeset for help on using the changeset viewer.