3 /* transport - low level communication (send/receive bunches of bytes) */
5 /* module's public interface exported within GRAS, but not to end user. */
7 /* Copyright (c) 2004 Martin Quinson. All rights reserved. */
9 /* This program is free software; you can redistribute it and/or modify it
10 * under the terms of the license (GNU LGPL) which comes with this package. */
12 #ifndef GRAS_TRP_INTERFACE_H
13 #define GRAS_TRP_INTERFACE_H
15 #include "portable.h" /* sometimes needed for fd_set */
20 extern int gras_opt_trp_nomoredata_on_close;
23 *** Main user functions
25 /* stable if we know the storage will keep as is until the next trp_flush */
26 XBT_PUBLIC(void) gras_trp_send(gras_socket_t sd, char *data, long int size, int stable);
27 XBT_PUBLIC(void) gras_trp_recv(gras_socket_t sd, char *data, long int size);
28 XBT_PUBLIC(void) gras_trp_flush(gras_socket_t sd);
30 /* Find which socket needs to be read next */
31 XBT_PUBLIC(gras_socket_t) gras_trp_select(double timeout);
33 /* Set the peer process name (used by messaging layer) */
34 XBT_PUBLIC(void) gras_socket_peer_proc_set(gras_socket_t sock,char*peer_proc);
41 typedef struct gras_trp_plugin_ s_gras_trp_plugin_t, *gras_trp_plugin_t;
44 struct gras_trp_plugin_ {
47 /* dst pointers are created and initialized with default values
48 before call to socket_client/server.
49 Retrive the info you need from there. */
50 void (*socket_client)(gras_trp_plugin_t self,
52 void (*socket_server)(gras_trp_plugin_t self,
55 gras_socket_t (*socket_accept)(gras_socket_t from);
58 /* socket_close() is responsible of telling the OS that the socket is over,
59 but should not free the socket itself (beside the specific part) */
60 void (*socket_close)(gras_socket_t sd);
62 /* send/recv may be buffered */
63 void (*send)(gras_socket_t sd,
65 unsigned long int size,
66 int stable /* storage will survive until flush*/);
67 int (*recv)(gras_socket_t sd,
69 unsigned long int size);
70 /* raw_send/raw_recv is never buffered (use it for measurement stuff) */
71 void (*raw_send)(gras_socket_t sd,
73 unsigned long int size);
74 int (*raw_recv)(gras_socket_t sd,
76 unsigned long int size);
78 /* flush has to make sure that the pending communications are achieved */
79 void (*flush)(gras_socket_t sd);
81 void *data; /* plugin-specific data */
83 /* exit is responsible for freeing data and telling the OS this plugin goes */
84 /* exit=NULL, data gets freed. (ie exit function needed only when data contains pointers) */
85 void (*exit)(gras_trp_plugin_t);
88 XBT_PUBLIC(gras_trp_plugin_t)
89 gras_trp_plugin_get_by_name(const char *name);
91 /* Data of this module specific to each process
92 * (used by sg_process.c to cleanup the SG channel cruft)
98 unsigned int name_len;
100 xbt_dynar_t sockets; /* all sockets known to this process */
101 int myport; /* Port on which I listen myself */
104 /* SG only elements. In RL, they are part of the OS ;) */
105 int chan; /* Formated messages channel */
106 int measChan; /* Unformated echange channel for performance measurement*/
108 } s_gras_trp_procdata_t,*gras_trp_procdata_t;
110 /* Display the content of our socket set (debugging purpose) */
111 XBT_PUBLIC(void) gras_trp_socketset_dump(const char *name);
113 #endif /* GRAS_TRP_INTERFACE_H */