Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Replace usleep for nanosleep
[simgrid.git] / src / xbt / xbt_socket_private.h
1 /* transport - low level communication (send/receive bunches of bytes)      */
2
3 /* module's private interface masked even to other parts of XBT.           */
4
5 /* Copyright (c) 2004, 2005, 2006, 2007, 2009, 2010. The SimGrid Team.
6  * 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 XBT_SOCKET_PRIVATE_H
12 #define XBT_SOCKET_PRIVATE_H
13
14 #include "xbt/sysdep.h"
15 #include "xbt/log.h"
16 #include "xbt/dynar.h"
17 #include "xbt/dict.h"
18 #include "xbt/socket.h"
19
20 /**
21  * s_xbt_trp_bufdata:
22  * 
23  * Description of a socket.
24  */
25 typedef struct s_xbt_trp_bufdata xbt_trp_bufdata_t;
26
27 typedef struct s_xbt_socket {
28
29   xbt_trp_plugin_t plugin;
30
31   unsigned incoming:1;          /* true if we can read from this sock */
32   unsigned outgoing:1;          /* true if we can write on this sock */
33   unsigned accepting:1;         /* true if master incoming sock in tcp */
34   unsigned meas:1;              /* true if this is an experiment socket instead of messaging */
35   unsigned valid:1;             /* false if a select returned that the peer has left, forcing us to "close" the socket */
36   unsigned moredata:1;          /* TCP socket use a buffer and read operation get as much 
37                                    data as possible. It is possible that several messages
38                                    are received in one shoot, and select won't catch them 
39                                    afterward again. 
40                                    This boolean indicates that this is the case, so that we
41                                    don't call select in that case.  Note that measurement
42                                    sockets are not concerned since they use the TCP
43                                    interface directly, with no buffer. */
44
45   unsigned recvd:1;             /* true if the recvd_val field contains one byte of the stream (that we peek'ed to check the socket validity) */
46   char recvd_val;               /* what we peeked from the socket, if any */
47
48   int refcount;                 /* refcounting on shared sockets */
49
50   unsigned long int buf_size;   /* what to say to the OS. 
51                                    Field here to remember it when accepting */
52
53   int sd;
54
55   void *data;                   /* userdata */
56   xbt_trp_bufdata_t *bufdata;   /* buffer userdata */
57 } s_xbt_socket_t;
58
59 void xbt_trp_tcp_setup(xbt_trp_plugin_t plug);
60
61 #endif                          /* XBT_SOCKET_PRIVATE_H */