3 /* transport - low level communication (send/receive bunches of bytes) */
5 /* module's public interface exported within GRAS, but not to end user. */
7 /* Authors: Martin Quinson */
8 /* Copyright (C) 2004 Martin Quinson. */
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. */
13 #ifndef GRAS_TRP_INTERFACE_H
14 #define GRAS_TRP_INTERFACE_H
17 *** Main user functions
19 gras_error_t gras_trp_chunk_send(gras_socket_t *sd,
22 gras_error_t gras_trp_chunk_recv(gras_socket_t *sd,
25 gras_error_t gras_trp_flush(gras_socket_t *sd);
27 /* Find which socket needs to be read next */
29 gras_trp_select(double timeout,
38 typedef struct gras_trp_plugin_ gras_trp_plugin_t;
41 struct gras_trp_plugin_ {
44 /* dst pointers are created and initialized with default values
45 before call to socket_client/server*/
46 gras_error_t (*socket_client)(gras_trp_plugin_t *self,
49 /* OUT */ gras_socket_t *dst);
50 gras_error_t (*socket_server)(gras_trp_plugin_t *self,
52 /* OUT */ gras_socket_t *dst);
54 gras_error_t (*socket_accept)(gras_socket_t *sock,
55 /* OUT */gras_socket_t **dst);
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 gras_error_t (*chunk_send)(gras_socket_t *sd,
65 gras_error_t (*chunk_recv)(gras_socket_t *sd,
69 /* flush has to make sure that the pending communications are achieved */
70 gras_error_t (*flush)(gras_socket_t *sd);
72 void *data; /* plugin-specific data */
74 /* exit is responsible for freeing data and telling the OS this plugin goes */
75 /* exit=NULL, data gets freed. (ie exit function needed only when data contains pointers) */
76 void (*exit)(gras_trp_plugin_t *);
80 gras_trp_plugin_get_by_name(const char *name,
81 gras_trp_plugin_t **dst);
83 #endif /* GRAS_TRP_INTERFACE_H */