Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* THREAD */
- void *thread_cliente (void *arg)
- {
- int n;
- char buffer[DIM];
- int sockfd1 = (int )arg;
- /* Le mensagem vindo do cliente */
- while (1) {
- bzero(buffer,DIM);
- n = read( sockfd1,buffer,DIM );
- if ( n<0 ) {
- fprintf( stderr,"ERROR reading from socket\n" );
- exit(3); }
- printf("Here is the message: %s\n",buffer);
- if (buffer[0]='i')
- {
- cria_mapa(rng_seed);
- /* Envia resposta ao cliente */
- n = write( sockfd1,"i",1 );
- if ( n<0 ) {
- fprintf( stderr,"ERROR writing to socket\n" );
- exit(3); }
- bzero(buffer,DIM);
- }
- else if (buffer[0]='d')
- {
- printf ("pedido de disparo");
- /* Envia resposta ao cliente */
- n = write( sockfd1,"dt41",4 );
- if ( n<0 ) {
- fprintf( stderr,"ERROR writing to socket\n" );
- exit(3); }
- bzero(buffer,DIM);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement