Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
resource file of context usage project
[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 #include <stdio.h>
11 #include "gras.h"
12 #include "gras/Transport/transport_interface.h"
13
14 XBT_LOG_NEW_CATEGORY(test,"Logging for this test");
15
16 int main(int argc,char *argv[]) {
17   gras_socket_t sock, conn;
18   char data_recv[256];
19
20   gras_init(&argc,argv);
21
22   fprintf(stderr,"===[SERVER]=== Create the socket\n");
23   sock = gras_socket_server(55555);
24
25   fprintf(stderr,"===[SERVER]=== Waiting for incomming connexions\n");
26   conn = gras_trp_select(60);
27
28   fprintf(stderr,"===[SERVER]=== Contacted ! Waiting for the data\n");
29   gras_trp_recv(conn,data_recv, sizeof(data_recv));
30   fprintf(stderr,"===[SERVER]=== Got '%s'. Send it back.\n", data_recv);
31   gras_trp_send(conn,data_recv, sizeof(data_recv),1);
32   gras_trp_flush(conn);
33   gras_socket_close(conn);
34
35   fprintf(stderr,"===[SERVER]=== Exiting successfully\n");
36   gras_socket_close(sock);
37
38   gras_exit();
39   return 0;
40 }