示例#1
0
const char *get_tcp_info(int peerfd)
{
	static char info[100] = {0};

	SAI localaddr = get_local_name(peerfd);
	SAI peeraddr = get_peer_addr(peerfd);
	snprintf(info, sizeof info, "%s:%d->%s:%d",
		get_addr_ip(&localaddr),
		get_addr_port(&localaddr),
		get_addr_ip(&peeraddr),
		get_addr_port(&peeraddr));

	return info;
}
示例#2
0
文件: observer.c 项目: xsoameix/rock
addr_info_t *
build_addr(char ** addr, char ** port) {
  addr_info_t hint = {0}, * res;
  get_addr_port(addr, port);
  getaddrinfo(* addr, * port, &hint, &res);
  return res;
}
示例#3
0
void game_state::process_join_request(udp_sock& my_server, byte_fetch& fetch, sockaddr_storage& who)
{
    int32_t found_end = fetch.get<int32_t>();

    if(found_end != canary_end)
        return;

    printf("Player joined %s:%s\n", get_addr_ip(who).c_str(), get_addr_port(who).c_str());

    add_player(my_server, who);
    ///really need to pipe back player id

    ///should really dynamically organise teams
    ///so actually that's what I'll do
    byte_vector vec;
    vec.push_back(canary_start);
    vec.push_back(message::CLIENTJOINACK);
    vec.push_back<int32_t>(player_list.back().id);
    vec.push_back(canary_end);

    udp_send_to(my_server, vec.ptr, (const sockaddr*)&who);

    printf("sending ack\n");
}