1 /* Copyright (c) 2006, 2007, 2010. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
10 int server(int argc, char *argv[])
12 gras_socket_t mysock; /* socket on which I listen */
13 gras_socket_t toclient; /* socket used to write to the client */
15 gras_init(&argc, argv);
17 gras_msgtype_declare("hello", NULL);
18 mysock = gras_socket_server(12345);
20 gras_msg_wait(60, "hello", &toclient, NULL /* no payload */ );
22 fprintf(stderr, "Cool, we received the message from %s:%d.\n",
23 gras_socket_peer_name(toclient),
24 gras_socket_peer_port(toclient));
30 int client(int argc, char *argv[])
32 gras_socket_t mysock; /* socket on which I listen */
33 gras_socket_t toserver; /* socket used to write to the server */
35 gras_init(&argc, argv);
37 gras_msgtype_declare("hello", NULL);
38 mysock = gras_socket_server_range(1024, 10000, 0, 0);
40 fprintf(stderr, "Client ready; listening on %d\n",
41 gras_socket_my_port(mysock));
43 gras_os_sleep(1.5); /* sleep 1 second and half */
44 toserver = gras_socket_client("Jacquelin", 12345);
46 gras_msg_send(toserver, "hello", NULL);
47 fprintf(stderr, "That's it, we sent the data to the server\n");