Project

General

Profile

Bug #5753 ยป rpc-timeout.c

Marcel Telka, 2015-03-26 02:12 PM

 
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <rpc/rpc.h>
4

    
5
int
6
main(int argc, char *argv[])
7
{
8
	CLIENT *c;
9
	struct timeval t = {0, 0};
10

    
11
	if (argc < 2 || argc > 3) {
12
		printf("Usage: %s hostname [timeout]\n", argv[0]);
13
		return 1;
14
	}
15

    
16
	if (argc == 3)
17
		t.tv_sec = atol(argv[2]);
18

    
19
	if (t.tv_sec == 0)
20
		t.tv_sec = 5;
21

    
22
	c = clnt_create_service_timed(argv[1], NULL, 1, 1, 1111, "tcp", &t);
23
	if (c == NULL) {
24
		printf("clnt_create_service_timed failed\n");
25
		return 1;
26
	}
27

    
28
	return 0;
29
}
    (1-1/1)