if(FD_ISSET(sock.socketfd, &readfds)){
/*n = receive_message(buf, MAXMESG, sock, &port) ; */
/*keep receiving messages until the socket is empty*/
while((n = receive_message(tmp, MAXMESG, sock, &port)) > 0)int copy = TRUE; /* in general, copy tmp to buf */
if (MessageCounter > 0) /* not first time through while */
if ( initialized && tmp[1]=='h' )/* New msg is a hear */
ParseSensoryData(buf, Memry); /* parse the sound */
if ( Memry->HeardNewSound() ) /* respond to it */
Communicate(behavior, Memry, &sock);
Memry->ClearSound(); /* Undo the sound bit */
copy = FALSE; /* Leave the last msg in buf */
#if PRINT_MISSED_MSGS
else if ( initialized )
printf(``Player %d-%c skipped a message %.40s ...n
before %.40s ...n'',
Memry->MyNumber,Memry->MySide,buf,tmp);
#endif
if (copy)
strcpy(buf,tmp);
if ( buf[1] == 'h' ) /* also stop if it's a ``hear'' */
break;
MessageCounter++;
MessageCounter = 0;
[Noda]