Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Modifying the API so as to prevent a use of the context that would make valgrind...
[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 /* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved.            */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10 #include <stdio.h>
11 #include "gras.h"
12 #include "gras/Transport/transport_interface.h"
13
14 /*XBT_LOG_NEW_DEFAULT_CATEGORY(test);*/
15
16 int main(int argc,char *argv[]) {
17   gras_socket_t sock;
18   xbt_error_t errcode;
19   char data_send[256];
20   char data_recv[256];
21
22   memset(data_send, 0, sizeof(data_send));
23   memset(data_recv, 0, sizeof(data_recv));
24
25   gras_init(&argc,argv,"trp.thresh=debug");
26
27   fprintf(stderr,"===[CLIENT]=== Contact the server\n");
28   TRYFAIL(gras_socket_client(NULL,55555,&sock));
29
30   sprintf(data_send,"Hello, I am a little test data to send.");
31   fprintf(stderr,"===[CLIENT]=== Send data\n");
32   TRYFAIL(gras_trp_chunk_send(sock,data_send, sizeof(data_send)));
33   TRYFAIL(gras_trp_flush(sock));
34   fprintf(stderr,"===[CLIENT]=== Waiting for the ACK\n");
35   TRYFAIL(gras_trp_chunk_recv(sock,data_recv, sizeof(data_recv)));
36   
37   if (strcmp(data_send, data_recv)) {
38     fprintf(stderr, "===[CLIENT]=== String sent != string received\n");
39     xbt_abort();
40   } 
41   fprintf(stderr,"===[CLIENT]=== Got a valid ACK\n");
42   
43   fprintf(stderr,"===[CLIENT]=== Exiting successfully\n");
44   gras_socket_close(sock);
45    
46   xbt_exit();
47   return 0;
48 }