Changeset - f3a93c423bde
[Not reviewed]
0 1 0
Christopher Esterhuyse - 5 years ago 2020-04-29 16:44:02
christopher.esterhuyse@gmail.com
cleaner example 6
1 file changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
examples/6_constraint_solve/main.c
Show inline comments
 
@@ -78,26 +78,27 @@ int main(int arg_c, char * argv[]) {
 
			check("bind native ", connector_bind_native(c, i*2));
 
			check("bind to putter ",
 
				connector_bind_active(c, i*2 + 1, addrs[addr_idx]));
 
		}
 
	}
 
	printf("connecting...\n");
 
	check("connect", connector_connect(c, 5000));
 
	check("connect", connector_connect(c, 3000));
 
	
 
	// for every native port, create a singleton batch
 
	for (i = 0; i < 3; i++) {
 
		if (i > 0) assert(connector_next_batch(c) >= 0);
 
		PeerInfo * pi = &peer_infos[i];
 
		check("op ", pi->puts?
 
			connector_get(c, i):
 
			connector_put(c, i, NULL, 0));
 
	}
 
	// solve!
 
	printf("solving...\n");
 
	int batch_idx = connector_sync(c, 3000);
 
	if (batch_idx < 0) printf("Error code on sync! %d\n", batch_idx);
 
	else printf("I was paired with peer %d\n", peer_infos[batch_idx].id);
 
	else printf("{ me: %d, peer: %d }\n", my_id, peer_infos[batch_idx].id);
 
	
 
	printf("destroying...\n");
 
	connector_destroy(c);
 
	printf("exiting...\n");
 
	free(pdl);
 
	return 0;
0 comments (0 inline, 0 general)