Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move big structures out of the stack to try to help the poor powerpc owner, but it...
[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_DEFAULT_CATEGORY(test);*/
15
16 int main(int argc,char *argv[]) {
17   gras_socket_t sock, conn;
18   xbt_error_t errcode;
19   char data_recv[256];
20
21   gras_init(&argc,argv,"trp.thresh=debug");
22
23   fprintf(stderr,"===[SERVER]=== Create the socket\n");
24   TRYFAIL(gras_socket_server(55555,&sock));
25
26   fprintf(stderr,"===[SERVER]=== Waiting for incomming connexions\n");
27   TRYFAIL(gras_trp_select(60,&conn));
28
29   fprintf(stderr,"===[SERVER]=== Contacted ! Waiting for the data\n");
30   TRYFAIL(gras_trp_chunk_recv(conn,data_recv, sizeof(data_recv)));
31   fprintf(stderr,"===[SERVER]=== Got '%s'. Send it back.\n", data_recv);
32   TRYFAIL(gras_trp_chunk_send(conn,data_recv, sizeof(data_recv)));
33   TRYFAIL(gras_trp_flush(conn));
34   gras_socket_close(conn);
35
36   fprintf(stderr,"===[SERVER]=== Exiting successfully\n");
37   gras_socket_close(sock);
38
39   gras_exit();
40   return 0;
41 }