示例#1
0
void
test_suite_setup()
{
	tnt = tnt_net(NULL);
	fail_if(tnt == NULL);

	tnt_set(tnt, TNT_OPT_HOSTNAME, "localhost");
	tnt_set(tnt, TNT_OPT_PORT, 33013);
	tnt_set(tnt, TNT_OPT_SEND_BUF, 128000);

	if (tnt_init(tnt) == -1)
		fail_tnt_perror("tnt_init");
	if (tnt_connect(tnt) == -1)
		fail_tnt_perror("tnt_connect");
}
示例#2
0
文件: tc.c 项目: cbin/tarantool
static void tc_connect(void)
{
	/* allocating stream */
	tc.net = tnt_net(NULL);
	if (tc.net == NULL)
		tc_error("stream allocation error");
	/* initializing network stream */
	tnt_set(tc.net, TNT_OPT_HOSTNAME, tc.opt.host);
	tnt_set(tc.net, TNT_OPT_PORT, tc.opt.port);
	tnt_set(tc.net, TNT_OPT_SEND_BUF, 0);
	tnt_set(tc.net, TNT_OPT_RECV_BUF, 0);
	if (tnt_init(tc.net) == -1)
		tc_error("%s", tnt_strerror(tc.net));
	/* connecting to server */
	if (tnt_connect(tc.net) == -1)
		tc_error("%s", tnt_strerror(tc.net));
}
示例#3
0
/*
 * tnt_rpl_open()
 *
 * connect to a server and initialize handshake;
 *
 * s   - replication stream pointer
 * lsn - start lsn 
 *
 * network stream must be properly initialized before
 * this function called (see ttnt_rpl_net, tnt_set).
 * 
 * returns 0 on success, or -1 on error.
*/
int tnt_rpl_open(struct tnt_stream *s, uint64_t lsn)
{
	struct tnt_stream_rpl *sr = TNT_RPL_CAST(s);
	/* intializing connection */
	if (tnt_init(sr->net) == -1)
		return -1;
	if (tnt_connect(sr->net) == -1)
		return -1;
	/* sending initial lsn */
	struct tnt_stream_net *sn = TNT_SNET_CAST(sr->net);
	if (tnt_io_send_raw(sn, (char*)&lsn, sizeof(lsn), 1) == -1)
		return -1;
	/* reading and checking version */
	uint32_t version = 0;
	if (tnt_io_recv_raw(sn, (char*)&version, sizeof(version), 1) == -1)
		return -1;
	if (version != tnt_rpl_version)
		return -1;
	return 0;
}