Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Moving sdp tests in maxmin_usage (to have the same set of tests).
[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 #ifdef __BORLANDC__
11 #pragma hdrstop
12 #endif
13
14 #include <stdio.h>
15 #include "gras.h"
16 #include "gras/Transport/transport_interface.h"
17
18 XBT_LOG_NEW_CATEGORY(test,"Logging for this test");
19
20 int main(int argc,char *argv[]) {
21   gras_socket_t sock;
22   char data_send[256];
23   char data_recv[256];
24
25   memset(data_send, 0, sizeof(data_send));
26   memset(data_recv, 0, sizeof(data_recv));
27
28   gras_init(&argc,argv);
29
30   fprintf(stderr,"===[CLIENT]=== Contact the server\n");
31   sock = gras_socket_client(NULL,55555);
32
33   sprintf(data_send,"Hello, I am a little test data to send.");
34   fprintf(stderr,"===[CLIENT]=== Send data\n");
35   gras_trp_send(sock,data_send, sizeof(data_send),1);
36   gras_trp_flush(sock);
37   fprintf(stderr,"===[CLIENT]=== Waiting for the ACK\n");
38   gras_trp_recv(sock,data_recv, sizeof(data_recv));
39   
40   if (strcmp(data_send, data_recv)) {
41     fprintf(stderr, "===[CLIENT]=== String sent != string received\n");
42     xbt_abort();
43   } 
44   fprintf(stderr,"===[CLIENT]=== Got a valid ACK\n");
45   
46   fprintf(stderr,"===[CLIENT]=== Exiting successfully\n");
47   gras_socket_close(sock);
48    
49   gras_exit();
50   return 0;
51 }