6 #include <sys/socket.h>
10 int main(int argc
, char **argv
)
13 struct sockaddr_in server
;
14 double beginTime
, endTime
;
15 int vetor
[VECTOR_SIZE
], vetorResposta
[VECTOR_SIZE
];
16 int vectorSize
= VECTOR_SIZE
* sizeof(int);
19 printf("Usage: %s <address> <port>\n", argv
[0]);
23 memset(&server
, 0, sizeof(server
));
24 server
.sin_family
= AF_INET
;
25 server
.sin_addr
.s_addr
= inet_addr(argv
[1]);
26 server
.sin_port
= htons(atoi(argv
[2]));
28 for(i
= 0; i
< VECTOR_SIZE
; i
++)
32 for(i
= 0; i
< TESTS_TOTAL
; i
++) {
34 printf("client: %i\n", i
);
37 mySocket
= socket(AF_INET
, SOCK_STREAM
, 0);
38 assert(mySocket
!= -1);
39 assert(connect(mySocket
, (struct sockaddr
*) &server
, sizeof(server
)) == 0);
43 for(j
= 0; j
< VECTOR_SIZE
; j
++)
44 printf("%i ", vetor
[j
]);
47 assert(send(mySocket
, vetor
, vectorSize
, 0) == vectorSize
);
48 assert(recv(mySocket
, vetorResposta
, vectorSize
, 0) == vectorSize
);
49 //assert(send(mySocket, NULL, 0, 0) == 0);
50 //assert(recv(mySocket, NULL, 0, 0) == 0);
54 for(j
= 0; j
< VECTOR_SIZE
; j
++)
55 printf("%i ", vetorResposta
[j
]);
61 printf("%g\n", ((endTime
- beginTime
) / (double) (TESTS_TOTAL
)) * (1000000 / (double) CLOCKS_PER_SEC
));