Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ONGOING work on exceptions plus minor cleanups.
[simgrid.git] / include / gras / transport.h
1 /* $Id$ */
2
3 /* transport - low level communication (send/receive bunches of bytes)      */
4 /* module's public interface exported to end user.                          */
5
6 /* Copyright (c) 2004 Martin Quinson. 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/error.h"
15
16 /** \addtogroup GRAS_sock
17  *  \brief Socket handling (Communication facility).
18  */
19
20 /** \name Socket creation functions
21  *  \ingroup GRAS_sock
22  */
23 /* @{*/
24 /** \brief Opaque type describing a socket */
25 typedef struct s_gras_socket *gras_socket_t;
26
27 /** \brief Simply create a client socket (to speak to a remote host) */
28 gras_socket_t gras_socket_client(const char *host, unsigned short port);
29 /** \brief Simply create a server socket (to ear from remote hosts speaking to you) */
30 gras_socket_t gras_socket_server(unsigned short port);
31 /** \brief Close socket */
32 void          gras_socket_close(gras_socket_t sd);
33
34 /** \brief Create a client socket, full interface to all relevant settings */
35 gras_socket_t gras_socket_client_ext(const char *host,
36                                      unsigned short port,
37                                      unsigned long int bufSize,
38                                      int measurement);
39 /** \brief Create a server socket, full interface to all relevant settings */
40 gras_socket_t gras_socket_server_ext(unsigned short port,
41                                      unsigned long int bufSize,
42                                      int measurement);
43 /* @}*/
44 /** \name Retrieving data about sockets and peers 
45  *  \ingroup GRAS_sock
46  * 
47  * Who are you talking to?
48  */
49 /* @{*/
50
51 /** Get the port number on which this socket is connected on my side */
52 int   gras_socket_my_port  (gras_socket_t sock);
53 /** Get the port number on which this socket is connected on remote side */
54 int   gras_socket_peer_port(gras_socket_t sock);
55 /** Get the host name of the remote side */
56 char *gras_socket_peer_name(gras_socket_t sock);
57 /* @}*/
58
59 /** \name Using measurement sockets
60  *  \ingroup GRAS_sock
61  * 
62  * You may want to use sockets not to exchange valuable data (in messages), 
63  * but to conduct some bandwidth measurements and related experiments. If so, try those measurement sockets.
64  * 
65  * You can only use those functions on sockets openned with the "measurement" boolean set to true.
66  * 
67  */
68 /* @{*/
69
70
71
72 int gras_socket_is_meas(gras_socket_t sock);
73 void gras_socket_meas_send(gras_socket_t peer, 
74                            unsigned int timeout,
75                            unsigned long int expSize, 
76                            unsigned long int msgSize);
77 void gras_socket_meas_recv(gras_socket_t peer, 
78                            unsigned int timeout,
79                            unsigned long int expSize, 
80                            unsigned long int msgSize);
81 gras_socket_t gras_socket_meas_accept(gras_socket_t peer);
82             
83 /* @}*/
84
85 /** \name Using files as sockets
86  *  \ingroup GRAS_sock
87  * 
88  * For debugging purpose, it is possible to deal with files as if they were sockets.
89  * It can even be useful to store stuff in a portable manner, but writing messages to a file
90  * may be strange...
91  * 
92  * \bug Don't use '-' on windows. this file represents stdin or stdout, but I failed to deal with it on windows.
93  */
94 /* @{*/
95 /* debuging functions */
96 gras_socket_t gras_socket_client_from_file(const char*path);
97 gras_socket_t gras_socket_server_from_file(const char*path);
98                                           
99 /* @} */
100    
101 #endif /* GRAS_TRANSPORT_H */