Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename bloc_send/recv to chunk_send/recv because I had a doubt on bloc meaning in...
[simgrid.git] / src / gras / Transport / transport_interface.h
1 /* $Id$ */
2
3 /* transport - low level communication (send/receive bunches of bytes)      */
4
5 /* module's public interface exported within GRAS, but not to end user.     */
6
7 /* Authors: Martin Quinson                                                  */
8 /* Copyright (C) 2004 Martin Quinson.                                       */
9
10 /* This program is free software; you can redistribute it and/or modify it
11    under the terms of the license (GNU LGPL) which comes with this package. */
12
13 #ifndef GRAS_TRP_INTERFACE_H
14 #define GRAS_TRP_INTERFACE_H
15
16 #include "gras_private.h"
17
18 /***
19  *** Main user functions
20  ***/
21 gras_error_t gras_trp_chunk_send(gras_socket_t *sd,
22                                  char *data,
23                                  size_t size);
24 gras_error_t gras_trp_chunk_recv(gras_socket_t *sd,
25                                  char *data,
26                                  size_t size);
27
28 /* Find which socket needs to be read next */
29 gras_error_t 
30 gras_trp_select(double timeout,
31                 gras_socket_t **dst);
32
33
34 /***
35  *** Module declaration 
36  ***/
37 gras_error_t gras_trp_init(void);
38 void         gras_trp_exit(void);
39
40 /***
41  *** Plugin mecanism 
42  ***/
43
44 /* A plugin type */
45 typedef struct gras_trp_plugin_ gras_trp_plugin_t;
46
47
48 /**
49  * e_gras_trp_plugin:
50  * 
51  * Caracterize each possible transport plugin
52  */
53 typedef enum e_gras_trp_plugin {
54    e_gras_trp_plugin_undefined = 0,
55      
56      e_gras_trp_plugin_tcp
57 } gras_trp_plugin_type_t;
58
59 /* A plugin type */
60 struct gras_trp_plugin_ {
61   char          *name;
62  
63   gras_error_t (*socket_client)(gras_trp_plugin_t *self,
64                                 const char *host,
65                                 unsigned short port,
66                                 unsigned int bufSize,
67                                 /* OUT */ gras_socket_t **dst);
68   gras_error_t (*socket_server)(gras_trp_plugin_t *self,
69                                 unsigned short port,
70                                 unsigned int bufSize,
71                                 /* OUT */ gras_socket_t **dst);
72   gras_error_t (*socket_accept)(gras_socket_t  *sock,
73                                 /* OUT */gras_socket_t **dst);
74    
75    
76    /* socket_close() is responsible of telling the OS that the socket is over,
77     but should not free the socket itself (beside the specific part) */
78   void         (*socket_close)(gras_socket_t *sd);
79     
80   gras_error_t (*chunk_send)(gras_socket_t *sd,
81                              char *data,
82                              size_t size);
83   gras_error_t (*chunk_recv)(gras_socket_t *sd,
84                              char *Data,
85                              size_t size);
86
87   void          *specific;
88   void         (*free_specific)(void *);
89 };
90
91 gras_error_t
92 gras_trp_plugin_get_by_name(const char *name,
93                             gras_trp_plugin_t **dst);
94
95 #endif /* GRAS_TRP_INTERFACE_H */