Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Taking latencies into account to bound the effective bandwidth.
[simgrid.git] / testsuite / gras / trp_tcp_client.c
1 /* $Id$ */
2
3 /* trp_tcp_client: Client of a test case for the tcp transport.             */
4
5 /* Authors: Martin Quinson                                                  */
6 /* Copyright (C) 2003 the OURAGAN project.                                  */
7
8 /* This program is free software; you can redistribute it and/or modify it
9    under the terms of the license (GNU LGPL) which comes with this package. */
10
11 #include <stdio.h>
12 #include <gras.h>
13 #include "gras/Transport/transport_interface.h"
14
15 /*XBT_LOG_NEW_DEFAULT_CATEGORY(test);*/
16
17 int main(int argc,char *argv[]) {
18   gras_socket_t sock;
19   xbt_error_t errcode;
20   char data_send[256];
21   char data_recv[256];
22
23   memset(data_send, 0, sizeof(data_send));
24   memset(data_recv, 0, sizeof(data_recv));
25
26   xbt_init_defaultlog(&argc,argv,"trp.thresh=debug");
27
28   fprintf(stderr,"===[CLIENT]=== Contact the server\n");
29   TRYFAIL(gras_socket_client(NULL,55555,&sock));
30
31   sprintf(data_send,"Hello, I am a little test data to send.");
32   fprintf(stderr,"===[CLIENT]=== Send data\n");
33   TRYFAIL(gras_trp_chunk_send(sock,data_send, sizeof(data_send)));
34   TRYFAIL(gras_trp_flush(sock));
35   fprintf(stderr,"===[CLIENT]=== Waiting for the ACK\n");
36   TRYFAIL(gras_trp_chunk_recv(sock,data_recv, sizeof(data_recv)));
37   
38   if (strcmp(data_send, data_recv)) {
39     fprintf(stderr, "===[CLIENT]=== String sent != string received\n");
40     xbt_abort();
41   } 
42   fprintf(stderr,"===[CLIENT]=== Got a valid ACK\n");
43   
44   fprintf(stderr,"===[CLIENT]=== Exiting successfully\n");
45   gras_socket_close(sock);
46    
47   xbt_exit();
48   return 0;
49 }