Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
forgot to propagate the last file renaming here.
[simgrid.git] / testsuite / gras / trp_tcp_server.c
1 /* $Id$ */
2
3 /* trp_tcp_server: Server 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 #ifdef __BORLANDC__
21 #pragma argsused
22 #endif
23
24 int main(int argc,char *argv[]) {
25   gras_socket_t sock, conn;
26   char data_recv[256];
27
28   gras_init(&argc,argv);
29
30   fprintf(stderr,"===[SERVER]=== Create the socket\n");
31   sock = gras_socket_server(55555);
32
33   fprintf(stderr,"===[SERVER]=== Waiting for incomming connexions\n");
34   conn = gras_trp_select(60);
35
36   fprintf(stderr,"===[SERVER]=== Contacted ! Waiting for the data\n");
37   gras_trp_recv(conn,data_recv, sizeof(data_recv));
38   fprintf(stderr,"===[SERVER]=== Got '%s'. Send it back.\n", data_recv);
39   gras_trp_send(conn,data_recv, sizeof(data_recv),1);
40   gras_trp_flush(conn);
41   gras_socket_close(conn);
42
43   fprintf(stderr,"===[SERVER]=== Exiting successfully\n");
44   gras_socket_close(sock);
45
46   gras_exit();
47   return 0;
48 }