Ejemplo n.º 1
0
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();
  }
}
Ejemplo n.º 2
0
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; 
}
Ejemplo n.º 3
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);
}
Ejemplo n.º 4
0
void tie(){
  printf("Tie\n");
  in_msg();
}
Ejemplo n.º 5
0
void lose(){
  printf("Player Loses\n");
  in_msg();
}
Ejemplo n.º 6
0
void win(){
  printf("Player Wins\n");
  in_msg();
}
Ejemplo n.º 7
0
void msg(){
  recv_msg(buf, 256, client_sock);
  printf("%s", buf);
  in_msg();
}