void inp(){ printf("Hit or stand? "); scanf("%s", buf); if(!strncmp(buf, "hit", 3)){ send_msg("hit", client_sock); in_msg(); }else if(!strncmp(buf, "stand", 4)){ send_msg("stand", client_sock); in_msg(); }else{ inp(); } }
int main( int argc, char *argv[] ) { if ( argc != 2 ) { printf( "Usage: client SERVER_IP_ADDRESS\n" ); return 1; } client_sock = client_connect( argv[ 1 ] ); in_msg(); terminate_socket( client_sock ); return 0; }
/** * Source callback, either performs in or out operation, depending on the event * type * @param src Underlying monitor source of the message source */ static void msg_cb(struct io_src *src) { struct io_src_msg *msg = to_src_msg(src); /* TODO treat I/O THEN errors */ if (io_src_has_error(src)) return; if (io_src_has_in(src)) { in_msg(msg, src->fd); return; } out_msg(msg, src->fd); }
void tie(){ printf("Tie\n"); in_msg(); }
void lose(){ printf("Player Loses\n"); in_msg(); }
void win(){ printf("Player Wins\n"); in_msg(); }
void msg(){ recv_msg(buf, 256, client_sock); printf("%s", buf); in_msg(); }