Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
7c33b4723f1299750a74f902343607a54bd2680e
[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 /* Authors: Martin Quinson                                                  */
6 /* Copyright (C) 2003 the OURAGAN project.                                  */
7
8 /* This program is free software; you can redistribute it and/or modify it
9    under the terms of the license (GNU LGPL) which comes with this package. */
10
11 #include <stdio.h>
12 #include <gras.h>
13 #include "../Transport/transport_interface.h"
14
15 //GRAS_LOG_NEW_DEFAULT_CATEGORY(test);
16
17 int main(int argc,char *argv[]) {
18   gras_socket_t *sock, *conn;
19   gras_error_t errcode;
20   char data_recv[256];
21
22   gras_init_defaultlog(argc,argv,"trp.thresh=debug");
23
24   fprintf(stderr,"===[SERVER]=== Create the socket\n");
25   TRYFAIL(gras_socket_server(55555,&sock));
26
27   fprintf(stderr,"===[SERVER]=== Waiting for incomming connexions\n");
28   TRYFAIL(gras_trp_select(60,&conn));
29
30   fprintf(stderr,"===[SERVER]=== Contacted ! Waiting for the data\n");
31   TRYFAIL(gras_trp_chunk_recv(conn,data_recv, sizeof(data_recv)));
32   fprintf(stderr,"===[SERVER]=== Got '%s'. Send it back.\n", data_recv);
33   TRYFAIL(gras_trp_chunk_send(conn,data_recv, sizeof(data_recv)));
34   gras_socket_close(&conn);
35
36   fprintf(stderr,"===[SERVER]=== Exiting successfully\n");
37   gras_socket_close(&sock);
38
39   return 0;
40 }