Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot//simgrid/simgrid
[simgrid.git] / include / gras / transport.h
1
2 /* transport - low level communication (send/receive bunches of bytes)      */
3 /* module's public interface exported to end user.                          */
4
5 /* Copyright (c) 2004, 2005, 2006, 2007, 2009, 2010. The SimGrid Team.
6  * All rights reserved.                                                     */
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 #ifndef GRAS_TRANSPORT_H
12 #define GRAS_TRANSPORT_H
13
14 #include "xbt/socket.h"
15
16 /** \addtogroup GRAS_sock
17  *  \brief Socket handling
18  *
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.
23  *
24  * The main difference is that you cannot exchange arbitrary bytes on
25  * sockets, but messages. See the \ref GRAS_msg section for details.
26  *
27  * If you need an example of how to use sockets, check \ref GRAS_ex_ping.
28  *
29  */
30
31 /** \defgroup GRAS_sock_create Socket creation functions
32  *  \ingroup GRAS_sock
33  *
34  */
35 /* @{*/
36
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,
39                                              unsigned short port);
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);
45
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,
48                                                 unsigned short port,
49                                                 unsigned long int bufSize,
50                                                 int measurement);
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,
54                                                 int measurement);
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);
58
59 /* @}*/
60
61 /** \defgroup GRAS_sock_file Using files as sockets
62  *  \ingroup GRAS_sock
63  * 
64  *
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
67  * may be strange...
68  * 
69  * \bug Don't use '-' on windows. this file represents stdin or stdout, but I failed to deal with it on windows.
70  */
71 /* @{*/
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);
75
76 /* @} */
77
78 void gras_trp_sg_setup(xbt_trp_plugin_t plug);
79 void gras_trp_file_setup(xbt_trp_plugin_t plug);
80
81 #endif                          /* GRAS_TRANSPORT_H */