Example #1
0
static int
discover_services(char *server)
{
    char buf[BUFSIZE];
    struct sockaddr_in addr;
    ssize_t rcount;
    socklen_t addr_len = sizeof(addr);
    int sock = create_sock(NULL, 5555);

    mcast_connect(sock, 51234);
    rcount = recvfrom(sock, buf, sizeof(buf), 0, (struct sockaddr*) &addr,
                      &addr_len);

    printf("recvd >> %s\n", buf);

    double diff = get_tcp_bw(&addr, 10);

    if (diff > 10) {
        inet_ntop(AF_INET, &(addr.sin_addr), server, 50);
        printf("server %s\n", server);
        printf("BW is greated than 10 MB, running over RPC\n");
        return 0;
    }
    else { 
        printf("BW is less than 10 MB, running locally\n");
        return -1;
    }
}
Example #2
0
static int
discover_services(char *server)
{
    char buf[BUFSIZE];
    struct sockaddr_in addr;
    ssize_t rcount;
    socklen_t addr_len = sizeof(addr);
    int sock = create_sock(NULL, 5555);

    mcast_connect(sock, 51234);
    rcount = recvfrom(sock, buf, sizeof(buf), 0, (struct sockaddr*) &addr,
                      &addr_len);
	printf("rcount: %s\n", buf);


    double diff = get_tcp_bw(&addr, 10);
	
    tcp_connect(&addr, 0);
}