2 /* transport - low level communication (send/receive bunches of bytes) */
3 /* module's public interface exported to end user. */
5 /* Copyright (c) 2004, 2005, 2006, 2007, 2009, 2010. The SimGrid Team.
6 * All rights reserved. */
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. */
11 #ifndef GRAS_TRANSPORT_H
12 #define GRAS_TRANSPORT_H
14 #include "xbt/socket.h"
16 /** \addtogroup GRAS_sock
17 * \brief Socket handling
19 * The model of communications in GRAS is very close to the BSD socket one.
20 * To get two hosts exchanging data, one of them need to open a
21 * <i>server</i> socket on which it can listen for incoming messages and the
22 * other one must connect a <i>client</i> socket onto the server one.
24 * The main difference is that you cannot exchange arbitrary bytes on
25 * sockets, but messages. See the \ref GRAS_msg section for details.
27 * If you need an example of how to use sockets, check \ref GRAS_ex_ping.
31 /** \defgroup GRAS_sock_create Socket creation functions
37 /** \brief Simply create a client socket (to speak to a remote host) */
38 XBT_PUBLIC(xbt_socket_t) gras_socket_client(const char *host,
40 XBT_PUBLIC(xbt_socket_t) gras_socket_client_from_string(const char *host);
41 /** \brief Simply create a server socket (to ear from remote hosts speaking to you) */
42 XBT_PUBLIC(xbt_socket_t) gras_socket_server(unsigned short port);
43 XBT_PUBLIC(void) gras_socket_close(xbt_socket_t sd);
44 XBT_PUBLIC(void) gras_socket_close_voidp(void *sock);
46 /** \brief Create a client socket, full interface to all relevant settings */
47 XBT_PUBLIC(xbt_socket_t) gras_socket_client_ext(const char *host,
49 unsigned long int bufSize,
51 /** \brief Create a server socket, full interface to all relevant settings */
52 XBT_PUBLIC(xbt_socket_t) gras_socket_server_ext(unsigned short port,
53 unsigned long int bufSize,
55 XBT_PUBLIC(xbt_socket_t)
56 gras_socket_server_range(unsigned short minport, unsigned short maxport,
57 unsigned long int buf_size, int measurement);
61 /** \defgroup GRAS_sock_file Using files as sockets
65 * For debugging purpose, it is possible to deal with files as if they were sockets.
66 * It can even be useful to store stuff in a portable manner, but writing messages to a file
69 * \bug Don't use '-' on windows. this file represents stdin or stdout, but I failed to deal with it on windows.
72 /* debuging functions */
73 XBT_PUBLIC(xbt_socket_t) gras_socket_client_from_file(const char *path);
74 XBT_PUBLIC(xbt_socket_t) gras_socket_server_from_file(const char *path);
78 void gras_trp_sg_setup(xbt_trp_plugin_t plug);
79 void gras_trp_file_setup(xbt_trp_plugin_t plug);
81 #endif /* GRAS_TRANSPORT_H */