~ubuntu-branches/ubuntu/raring/simgrid/raring

« back to all changes in this revision

Viewing changes to examples/gras/mmrpc/mmrpc_server.c

  • Committer: Package Import Robot
  • Author(s): Lucas Nussbaum
  • Date: 2012-05-24 16:08:59 UTC
  • mfrom: (10.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120524160859-vhdlh05p313l5662
Tags: 3.7-1
* New upstream release.
* Bump Standards-Version to 3.9.3. No changes needed.
* debian/rules: Enable the SMPI library in the package. Closes: #656102.
* Build with -O2 on ia64. Closes: #640538.
* Use dpkg-buildflags to generate CFLAGS and LDFLAGS. Enable hardening.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
/* This program is free software; you can redistribute it and/or modify it
7
7
 * under the terms of the license (GNU LGPL) which comes with this package. */
8
8
 
9
 
#define GRAS_DEFINE_TYPE_EXTERN
 
9
#define XBT_DEFINE_TYPE_EXTERN
10
10
#include "xbt/matrix.h"
11
11
#include "mmrpc.h"
12
12
 
18
18
                                     void *payload_data)
19
19
{
20
20
 
21
 
  gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
 
21
  xbt_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
22
22
 
23
23
  /* 1. Get the payload into the data variable */
24
24
  xbt_matrix_t *request = (xbt_matrix_t *) payload_data;
38
38
  return 0;
39
39
}                               /* end_of_server_cb_request_handler */
40
40
 
 
41
static xbt_socket_t try_gras_socket_server(int port)
 
42
{
 
43
  volatile xbt_socket_t sock = NULL;
 
44
  TRY {
 
45
    sock = gras_socket_server(port);
 
46
  }
 
47
  CATCH_ANONYMOUS {
 
48
    RETHROWF("Unable to establish a server socket: %s");
 
49
  }
 
50
  return sock;
 
51
}
 
52
 
41
53
int server(int argc, char *argv[])
42
54
{
43
 
  gras_socket_t sock = NULL;
 
55
  xbt_socket_t sock = NULL;
44
56
  int port = 4002;
45
57
 
46
58
  /* 1. Init the GRAS infrastructure */
51
63
    port = atoi(argv[1]);
52
64
  }
53
65
 
54
 
  /* 3. Create my master socket */
55
 
  XBT_INFO("Launch server (port=%d)", port);
56
 
  TRY {
57
 
    sock = gras_socket_server(port);
58
 
  }
59
 
  CATCH_ANONYMOUS {
60
 
    RETHROWF("Unable to establish a server socket: %s");
61
 
  }
62
 
 
63
 
  /* 4. Register the known messages and payloads. */
 
66
  /* 3. Register the known messages and payloads. */
64
67
  mmrpc_register_messages();
65
68
 
66
 
  /* 5. Register my callback */
 
69
  /* 4. Register my callback */
67
70
  gras_cb_register("request", &server_cb_request_handler);
68
71
 
 
72
  /* 5. Create my master socket */
 
73
  XBT_INFO("Launch server (port=%d)", port);
 
74
  sock = try_gras_socket_server(port);
 
75
 
69
76
  /* 6. Wait up to 10 minutes for an incomming message to handle */
70
77
  gras_msg_handle(600.0);
71
78