示例#1
0
文件: main.c 项目: Londontown/skynet
static void
_expand(struct connection_server * server) {
	connection_deletepool(server->pool);
	server->pool = connection_newpool(server->max_connection * 2);
	int i;
	for (i=0;i<server->max_connection;i++) {
		struct connection * c = &server->conn[i];
		int err = connection_add(server->pool, c->fd , c);
		assert(err == 0);
	}
	server->max_connection *= 2;
}
示例#2
0
int
main() {
	struct connection_pool * p = connection_newpool(16);

	int handle = connection_open(p, "127.0.0.1:8888");

	test(p,handle);

	connection_deletepool(p);
	
	return 0;
};
示例#3
0
文件: main.c 项目: Londontown/skynet
int
connection_init(struct connection_server * server, struct skynet_context * ctx, char * param) {
	server->pool = connection_newpool(DEFAULT_CONNECTION);
	if (server->pool == NULL)
		return 1;
	server->max_connection = strtol(param, NULL, 10);
	if (server->max_connection == 0) {
		server->max_connection = DEFAULT_CONNECTION;
	}
	server->current_connection = 0;
	server->ctx = ctx;
	server->conn = malloc(server->max_connection * sizeof(struct connection));
	memset(server->conn, 0, server->max_connection * sizeof(struct connection));

	skynet_callback(ctx, server, _connection_main);
	skynet_command(ctx,"REG",".connection");
	skynet_command(ctx,"TIMEOUT","0");
	return 0;
}