~ubuntu-branches/ubuntu/wily/ncbi-tools6/wily

« back to all changes in this revision

Viewing changes to connect/ncbi_socketp.h

  • Committer: Package Import Robot
  • Author(s): Aaron M. Ucko, Andreas Tille
  • Date: 2012-06-24 22:54:29 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20120624225429-y81u0gzrppi3fhyf
Tags: 6.1.20120620-2
[ Andreas Tille ]
debian/upstream: Strings containing ': ' need to be quoted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef CONNECT___NCBI_SOCKETP__H
2
2
#define CONNECT___NCBI_SOCKETP__H
3
3
 
4
 
/* $Id: ncbi_socketp.h,v 1.23 2010/10/21 20:24:31 kazimird Exp $
 
4
/* $Id: ncbi_socketp.h,v 1.26 2012/05/04 19:04:38 kazimird Exp $
5
5
 * ===========================================================================
6
6
 *
7
7
 *                            PUBLIC DOMAIN NOTICE
58
58
 */
59
59
#include <errno.h>
60
60
 
 
61
#ifdef __cplusplus
 
62
extern "C" {
 
63
#endif /*__cplusplus*/
 
64
 
61
65
#ifdef NCBI_OS_MSWIN
62
66
 
63
 
typedef SOCKET TSOCK_Handle;
64
 
typedef HANDLE TRIGGER_Handle;
 
67
typedef SOCKET TSOCK_Handle;    /* NB: same as HANDLE   */
 
68
typedef HANDLE TRIGGER_Handle;  /* NB: same as WSAEVENT */
65
69
 
66
70
#  ifdef _WIN64
67
71
#    pragma pack(push, 4)
134
138
#if 0/*defined(__GNUC__)*/
135
139
typedef ESwitch    EBSwitch;
136
140
typedef EIO_Status EBIO_Status;
137
 
typedef ESOCK_Side EBSOCK_Side;
138
141
#else
139
142
typedef unsigned   EBSwitch;
140
143
typedef unsigned   EBIO_Status;
141
 
typedef unsigned   EBSOCK_Side;
142
144
#endif
143
145
 
144
146
 
145
147
typedef enum {
146
 
    eInvalid   = 0,
 
148
    eListening = 0,
147
149
    eTrigger   = 1,
148
150
    eSocket    = 2,
149
 
    eDatagram  = 3/*2|1*/,
150
 
    eListening = 4
 
151
    eDatagram  = 3/*2|1*/
151
152
} ESOCK_Type;
152
 
typedef unsigned char TSOCK_Type;
 
153
 
 
154
typedef unsigned TBSOCK_Type;
153
155
 
154
156
 
155
157
/* Event trigger
164
166
    } isset;
165
167
 
166
168
    /* type, status, EOF, log, read-on-write etc bit-field indicators */
167
 
    TSOCK_Type          type;   /* eTrigger                                  */
 
169
    TBSOCK_Type         type:2; /* eTrigger                                  */
168
170
    EBSwitch             log:2; /* how to log events                         */
169
 
    EBSOCK_Side         side:1; /* MBZ                                       */
170
 
    unsigned/*bool*/    keep:1; /* MBZ                                       */
171
171
    EBSwitch          r_on_w:2; /* MBZ                                       */
172
172
    EBSwitch        i_on_sig:2; /* eDefault                                  */
 
173
 
173
174
    EBIO_Status     r_status:3; /* MBZ (NB: eIO_Success)                     */
174
175
    unsigned/*bool*/     eof:1; /* MBZ                                       */
175
176
    EBIO_Status     w_status:3; /* MBZ (NB: eIO_Success)                     */
176
177
    unsigned/*bool*/ pending:1; /* MBZ                                       */
177
178
 
178
 
    unsigned        reserved:8; /* MBZ                                       */
 
179
    unsigned        reserved:16;/* MBZ                                       */
179
180
 
180
181
#ifdef NCBI_OS_UNIX
181
182
    int                out;     /* write end of the pipe                     */
183
184
} TRIGGER_struct;
184
185
 
185
186
 
 
187
/* Sides of socket
 
188
 */
 
189
typedef enum {
 
190
    eSOCK_Server = 0,
 
191
    eSOCK_Client = 1
 
192
} ESOCK_Side;
 
193
 
 
194
typedef unsigned EBSOCK_Side;
 
195
 
 
196
 
186
197
/* Listening socket [must be in one-2-one binary correspondene with TRIGGER]
187
198
 */
188
199
typedef struct LSOCK_tag {
194
205
    unsigned short   port;      /* port on which listening (host byte order) */
195
206
 
196
207
    /* type, status, EOF, log, read-on-write etc bit-field indicators */
197
 
    TSOCK_Type          type;   /* eListening                                */
 
208
    TBSOCK_Type         type:2; /* eListening                                */
198
209
    EBSwitch             log:2; /* how to log events and data for this socket*/
199
 
    EBSOCK_Side         side:1; /* MBZ                                       */
200
 
    unsigned/*bool*/    keep:1; /* MBZ                                       */
201
210
    EBSwitch          r_on_w:2; /* MBZ                                       */
202
211
    EBSwitch        i_on_sig:2; /* eDefault                                  */
 
212
 
203
213
    EBIO_Status     r_status:3; /* MBZ (NB: eIO_Success)                     */
204
214
    unsigned/*bool*/     eof:1; /* MBZ                                       */
205
215
    EBIO_Status     w_status:3; /* MBZ (NB: eIO_Success)                     */
206
216
    unsigned/*bool*/ pending:1; /* MBZ                                       */
207
217
 
 
218
    EBSOCK_Side         side:1; /* MBZ (NB: eSOCK_Server)                    */
 
219
    unsigned/*bool*/    keep:1; /* whether to keep OS handle upon close      */
208
220
#ifndef NCBI_OS_MSWIN
209
 
    unsigned        reserved:8; /* MBZ                                       */
 
221
    unsigned        reserved:14;/* MBZ                                       */
210
222
#else
211
 
    unsigned        reserved:5; /* MBZ                                       */
 
223
    unsigned        reserved:11;/* MBZ                                       */
212
224
    unsigned        readable:1; /* =1 if known to have a pending accept      */
213
225
    unsigned          unused:2; /* MBZ                                       */
214
226
 
215
 
        WSAEVENT         event;     /* event bound to I/O                        */
 
227
    WSAEVENT         event;     /* event bound to I/O                        */
216
228
#endif /*!NCBI_OS_MSWIN*/
217
229
 
218
230
    void*            context;   /* per-server credentials                    */
223
235
} LSOCK_struct;
224
236
 
225
237
 
226
 
/* Sides of connecting socket
227
 
 */
228
 
typedef enum {
229
 
    eSOCK_Client = 0,
230
 
    eSOCK_Server = 1
231
 
} ESOCK_Side;
232
 
 
233
 
 
234
238
/* Socket [it must be in 1-2-1 binary correspondence with LSOCK above]
235
239
 */
236
240
typedef struct SOCK_tag {
243
247
    unsigned short   myport;    /* this socket's port number, host byte order*/
244
248
 
245
249
    /* type, status, EOF, log, read-on-write etc bit-field indicators */
246
 
    TSOCK_Type          type;   /* |= eSocket ({ eSocket | eDatagram })      */
 
250
    TBSOCK_Type         type:2; /* |= eSocket ({ eSocket | eDatagram })      */
247
251
    EBSwitch             log:2; /* how to log events and data for this socket*/
248
 
    EBSOCK_Side         side:1; /* socket side: client- or server-side       */
249
 
    unsigned/*bool*/    keep:1; /* whether to keep OS handle upon close      */
250
252
    EBSwitch          r_on_w:2; /* enable/disable automatic read-on-write    */
251
253
    EBSwitch        i_on_sig:2; /* enable/disable I/O restart on signals     */
252
254
 
256
258
    EBIO_Status     w_status:3; /* write status:  eIO_Closed if was shut down*/
257
259
    unsigned/*bool*/ pending:1; /* =1 if connection is still initing         */
258
260
 
 
261
    EBSOCK_Side         side:1; /* socket side: client- or server-side       */
 
262
    unsigned/*bool*/    keep:1; /* whether to keep OS handle upon close      */
259
263
    unsigned       crossexec:1; /* =1 if close-on-exec must NOT be set       */
260
264
    unsigned       connected:1; /* =1 if remote end-point is fully connected */
 
265
    unsigned        r_tv_set:1; /* =1 if read  timeout is set (i.e. finite)  */
 
266
    unsigned        w_tv_set:1; /* =1 if write timeout is set (i.e. finite)  */
 
267
    unsigned        c_tv_set:1; /* =1 if close timeout is set (i.e. finite)  */
261
268
    unsigned       keepalive:1; /* =1 if needs to be kept alive (if OS supp.)*/
262
269
#ifndef NCBI_OS_MSWIN
 
270
    unsigned        reserved:8; /* MBZ                                       */
 
271
#else
263
272
    unsigned        reserved:5; /* MBZ                                       */
264
 
#else
265
 
    unsigned        reserved:2; /* MBZ                                       */
266
273
    unsigned        readable:1; /* =1 if known to be readable                */
267
274
    unsigned        writable:1; /* =1 if known to be writeable               */
268
275
    unsigned         closing:1; /* =1 if FD_CLOSE posted                     */
269
276
 
270
 
        WSAEVENT         event;     /* event bound to I/O                        */
 
277
    WSAEVENT         event;     /* event bound to I/O                        */
271
278
#endif /*!NCBI_OS_MSWIN*/
272
279
 
273
280
    void*            session;   /* secure session id if secure, else 0       */
274
281
 
275
 
        /* timeouts */
276
 
    const struct timeval* r_timeout;/* NULL if infinite, or points to "r_tv" */
 
282
    /* timeouts */
277
283
    struct timeval   r_tv;      /* finite read  timeout value                */
 
284
    struct timeval   w_tv;      /* finite write timeout value                */
 
285
    struct timeval   c_tv;      /* finite close timeout value                */
278
286
    STimeout         r_to;      /* finite read  timeout value (aux., temp.)  */
279
 
    const struct timeval* w_timeout;/* NULL if infinite, or points to "w_tv" */
280
 
    struct timeval   w_tv;      /* finite write timeout value                */
281
287
    STimeout         w_to;      /* finite write timeout value (aux., temp.)  */
282
 
    const struct timeval* c_timeout;/* NULL if infinite, or points to "c_tv" */
283
 
    struct timeval   c_tv;      /* finite close timeout value                */
284
288
    STimeout         c_to;      /* finite close timeout value (aux., temp.)  */
285
289
 
286
290
    /* aux I/O data */
348
352
#endif /*NCBI_OS_MSWIN && _WIN64*/
349
353
 
350
354
 
 
355
extern const char g_kNcbiSockNameAbbr[];
 
356
 
 
357
 
 
358
#ifdef __cplusplus
 
359
} /* extern "C" */
 
360
#endif /*__cplusplus*/
 
361
 
 
362
 
351
363
#endif /* CONNECT___NCBI_SOCKETP__H */