cte-chat-threaded.c
void *print_message(void *ptr)
  {
    int    *sock_desc;                 /* pointer for parameter              */
    int    read_char;                  /* read characters                    */
    char   text1[BUFFERSIZE];          /* reading buffer                     */

    sock_desc = (int *)ptr;
    while(1)
      {
        read_char = recvfrom(*sock_desc,text1,BUFFERSIZE,0,NULL,NULL);
        text1[read_char] = '\0';
        printf("%s\n",text1);
        if (strcmp(text1, "Exit Game Mode"))
          game = 0;
      }
}
/* ------------------------------------------------------------------------- */
/* print_message()                                                           */
/*                                                                           */
/* this function will constantly look for a new message to print coming from */
/* the server                                                                */
/* void *ptr  - pointer that will receive the parameters for the thread      */
/*                                                                           */
/* ------------------------------------------------------------------------- */


this function will constantly look for a new message to print coming from
the server
void *ptr  - pointer that will receive the parameters for the thread
this function will constantly look for a new message to print coming from the server void * ptr - pointer that will receive the parameters for the thread
void *print_message(void *ptr)
  {
    int    *sock_desc;                 
    int    read_char;                  
    char   text1[BUFFERSIZE];          
    sock_desc = (int *)ptr;
    while(1)
      {
        read_char = recvfrom(*sock_desc,text1,BUFFERSIZE,0,NULL,NULL);
        text1[read_char] = '\0';
        printf("%s\n",text1);
        if (strcmp(text1, "Exit Game Mode"))
          game = 0;
      }
}
void * print_message ( void * ptr ) { int * sock_desc ; int read_char ; char text1 [ BUFFERSIZE ] ; sock_desc = ( int * ) ptr ; while ( 1 ) { read_char = recvfrom ( * sock_desc , text1 , BUFFERSIZE , 0 , NULL , NULL ) ; text1 [ read_char ] = ' \0 ' ; printf ( " \n " , text1 ) ; if ( strcmp ( text1 , " " ) ) game = 0 ; } }
print_message()
print_message ()
/* pointer for parameter              */ /* read characters                    */ /* reading buffer                     */