while(1){ printf("cmd (? for help)> "); scanf("%s",str); if(strcmp(str,"?")==0){ printChoice(state); }else if((strcmp(str,"1") == 0) && state == 0){ write(sock, str, strlen(str)); // write command to socket host /* fprintf(stderr,"sock er: %d ", sock); */ int read_check = check_read(sock, str); if (read_check == 1){ int sockread = readsock(sock, str); if (sockread == 0){ fprintf(stderr,"There was a fault in sockread"); } } }else{ write(sock, "0", 1); } /* read data */ //read(sock, buf,strlen(str)); fflush(stdin); bzero(str,299); }