X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c42000db0f347a26ac1645d830ac949194ec4da0..3e0633f41cb1ab62db77bac6ad9bda9ee02ddd43:/include/gras/transport.h
diff --git a/include/gras/transport.h b/include/gras/transport.h
index 32a5cdb3c4..2d8961ebf7 100644
--- a/include/gras/transport.h
+++ b/include/gras/transport.h
@@ -1,60 +1,127 @@
/* $Id$ */
/* transport - low level communication (send/receive bunches of bytes) */
-
/* module's public interface exported to end user. */
-/* Authors: Martin Quinson */
-/* Copyright (C) 2004 Martin Quinson. */
+/* Copyright (c) 2004 Martin Quinson. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
- under the terms of the license (GNU LGPL) which comes with this package. */
+ * under the terms of the license (GNU LGPL) which comes with this package. */
#ifndef GRAS_TRANSPORT_H
#define GRAS_TRANSPORT_H
-#include "xbt/error.h"
-
-typedef struct s_gras_socket gras_socket_t;
-
-gras_error_t gras_socket_client(const char *host,
- unsigned short port,
- /* OUT */ gras_socket_t **dst);
-gras_error_t gras_socket_server(unsigned short port,
- /* OUT */ gras_socket_t **dst);
-void gras_socket_close(gras_socket_t *sd);
-
-/* get information about socket */
-int gras_socket_my_port (gras_socket_t *sock);
-int gras_socket_peer_port(gras_socket_t *sock);
-char *gras_socket_peer_name(gras_socket_t *sock);
-
-/* extended interface to get all details */
-gras_error_t gras_socket_client_ext(const char *host,
- unsigned short port,
- unsigned long int bufSize,
- int raw,
- /* OUT */ gras_socket_t **dst);
-gras_error_t gras_socket_server_ext(unsigned short port,
- unsigned long int bufSize,
- int raw,
- /* OUT */ gras_socket_t **dst);
-
-/* using raw sockets */
-gras_error_t gras_socket_raw_send(gras_socket_t *peer,
- unsigned int timeout,
- unsigned long int expSize,
- unsigned long int msgSize);
-gras_error_t gras_socket_raw_recv(gras_socket_t *peer,
- unsigned int timeout,
- unsigned long int expSize,
- unsigned long int msgSize);
+/** \addtogroup GRAS_sock
+ * \brief Socket handling (Communication facility).
+ *
+ *
Top | [\ref index]::[\ref GRAS_API]
+ * |
Prev | [\ref GRAS_dd]
+ * |
Next | [\ref GRAS_msg]
+ * |
Down | [\ref GRAS_sock_create] |
+ *
+ * The model of communications in GRAS is very close to the BSD socket one. To get two hosts
+ * exchanging data, one of them need to open a server socket on which it can listen for incoming messages
+ * and the other one must connect a client socket onto the server one.
+ *
+ * If you need an example of this, check \ref GRAS_ex_ping.
+ *
+ */
+
+/** \defgroup GRAS_sock_create Socket creation functions
+ * \ingroup GRAS_sock
+ *
+ * Top | [\ref index]::[\ref GRAS_API]::[\ref GRAS_sock]
+ * |
Prev |
+ * |
Next | [\ref GRAS_sock_info] |
+ */
+/* @{*/
+/** \brief Opaque type describing a socket */
+typedef struct s_gras_socket *gras_socket_t;
+
+/** \brief Simply create a client socket (to speak to a remote host) */
+gras_socket_t gras_socket_client(const char *host, unsigned short port);
+/** \brief Simply create a server socket (to ear from remote hosts speaking to you) */
+gras_socket_t gras_socket_server(unsigned short port);
+/** \brief Close socket */
+void gras_socket_close(gras_socket_t sd);
+
+/** \brief Create a client socket, full interface to all relevant settings */
+gras_socket_t gras_socket_client_ext(const char *host,
+ unsigned short port,
+ unsigned long int bufSize,
+ int measurement);
+/** \brief Create a server socket, full interface to all relevant settings */
+gras_socket_t gras_socket_server_ext(unsigned short port,
+ unsigned long int bufSize,
+ int measurement);
+/* @}*/
+/** \defgroup GRAS_sock_info Retrieving data about sockets and peers
+ * \ingroup GRAS_sock
+ *
+ * Top | [\ref index]::[\ref GRAS_API]::[\ref GRAS_sock]
+ * |
Prev | [\ref GRAS_sock_create]
+ * |
Next | [\ref GRAS_sock_meas] |
+ *
+ * Who are you talking to?
+ */
+/* @{*/
+
+/** Get the port number on which this socket is connected on my side */
+int gras_socket_my_port (gras_socket_t sock);
+/** Get the port number on which this socket is connected on remote side */
+int gras_socket_peer_port(gras_socket_t sock);
+/** Get the host name of the remote side */
+char *gras_socket_peer_name(gras_socket_t sock);
+/* @}*/
+
+/** \defgroup GRAS_sock_meas Using measurement sockets
+ * \ingroup GRAS_sock
+ *
+ * Top | [\ref index]::[\ref GRAS_API]::[\ref GRAS_sock]
+ * |
Prev | [\ref GRAS_sock_info]
+ * |
Next | [\ref GRAS_sock_file] |
+ *
+ * You may want to use sockets not to exchange valuable data (in messages),
+ * but to conduct some bandwidth measurements and related experiments. If so, try those measurement sockets.
+ *
+ * You can only use those functions on sockets openned with the "measurement" boolean set to true.
+ *
+ */
+/* @{*/
+
+
+
+int gras_socket_is_meas(gras_socket_t sock);
+void gras_socket_meas_send(gras_socket_t peer,
+ unsigned int timeout,
+ unsigned long int expSize,
+ unsigned long int msgSize);
+void gras_socket_meas_recv(gras_socket_t peer,
+ unsigned int timeout,
+ unsigned long int expSize,
+ unsigned long int msgSize);
+gras_socket_t gras_socket_meas_accept(gras_socket_t peer);
+
+/* @}*/
+/** \defgroup GRAS_sock_file Using files as sockets
+ * \ingroup GRAS_sock
+ *
+ * Top | [\ref index]::[\ref GRAS_API]::[\ref GRAS_sock]
+ * |
Prev | [\ref GRAS_sock_meas]
+ * |
Next | |
+ *
+ * For debugging purpose, it is possible to deal with files as if they were sockets.
+ * It can even be useful to store stuff in a portable manner, but writing messages to a file
+ * may be strange...
+ *
+ * \bug Don't use '-' on windows. this file represents stdin or stdout, but I failed to deal with it on windows.
+ */
+/* @{*/
/* debuging functions */
-gras_error_t gras_socket_client_from_file(const char*path,
- /* OUT */ gras_socket_t **dst);
-gras_error_t gras_socket_server_from_file(const char*path,
- /* OUT */ gras_socket_t **dst);
+gras_socket_t gras_socket_client_from_file(const char*path);
+gras_socket_t gras_socket_server_from_file(const char*path);
+/* @} */
#endif /* GRAS_TRANSPORT_H */