Rudiments: /home/dmuse/src/rudiments/include/rudiments/filedescriptor.h Source File

Rudiments

- Main Page
- Classes

filedescriptor.h
1 // Copyright (c) 2002 David Muse
2 // See the COPYING file for more information.
3
4 #ifndef RUDIMENTS_FILEDESCRIPTOR_H
5 #define RUDIMENTS_FILEDESCRIPTOR_H
6
7 #include <rudiments/private/filedescriptorincludes.h>
8
9 class listener;
10 class filedescriptorprivate;
11
14 class RUDIMENTS_DLLSPEC filedescriptor {
15 public:
17 filedescriptor();
18
21 filedescriptor(const filedescriptor &f);
22
25 filedescriptor &operator=(const filedescriptor &f);
26
29 virtual ~filedescriptor();
30
33 virtual bool close();
34
36 int32_t getFileDescriptor() const;
37
40 void setFileDescriptor(int32_t filedesc);
41
51 int32_t duplicate() const;
52
59 bool duplicate(int32_t newfd) const;
60
63 void setSecurityContext(securitycontext *ctx);
64
68 securitycontext *getSecurityContext();
69
72 virtual bool supportsBlockingNonBlockingModes();
73
77 virtual bool useNonBlockingMode() const;
78
82 virtual bool useBlockingMode() const;
83
86 virtual bool isUsingNonBlockingMode() const;
87
91 ssize_t write(uint16_t number) const;
92
96 ssize_t write(uint32_t number) const;
97
101 ssize_t write(uint64_t number) const;
102
106 ssize_t write(int16_t number) const;
107
111 ssize_t write(int32_t number) const;
112
116 ssize_t write(int64_t number) const;
117
121 ssize_t write(float number) const;
122
126 ssize_t write(double number) const;
127
131 ssize_t write(unsigned char character) const;
132
136 ssize_t write(char character) const;
137
141 ssize_t write(bool value) const;
142
146 ssize_t write(const unsigned char *string) const;
147
151 ssize_t write(const char *string) const;
152
158 ssize_t write(const unsigned char *string, size_t size) const;
159
165 ssize_t write(const char *string, size_t size) const;
166
170 ssize_t write(const void *buffer, size_t size) const;
171
177 ssize_t write(uint16_t number, int32_t sec, int32_t usec) const;
178
184 ssize_t write(uint32_t number, int32_t sec, int32_t usec) const;
185
191 ssize_t write(uint64_t number, int32_t sec, int32_t usec) const;
192
198 ssize_t write(int16_t number, int32_t sec, int32_t usec) const;
199
205 ssize_t write(int32_t number, int32_t sec, int32_t usec) const;
206
212 ssize_t write(int64_t number, int32_t sec, int32_t usec) const;
213
219 ssize_t write(float number, int32_t sec, int32_t usec) const;
220
226 ssize_t write(double number, int32_t sec, int32_t usec) const;
227
233 ssize_t write(unsigned char character,
234 int32_t sec, int32_t usec) const;
235
241 ssize_t write(char character, int32_t sec, int32_t usec) const;
242
248 ssize_t write(bool value, int32_t sec, int32_t usec) const;
249
255 ssize_t write(const unsigned char *string,
256 int32_t sec, int32_t usec) const;
257
263 ssize_t write(const char *string,
264 int32_t sec, int32_t usec) const;
265
272 ssize_t write(const unsigned char *string, size_t size,
273 int32_t sec, int32_t usec) const;
274
281 ssize_t write(const char *string, size_t size,
282 int32_t sec, int32_t usec) const;
283
289 ssize_t write(const void *buffer, size_t size,
290 int32_t sec, int32_t usec) const;
291
294 size_t printf(const char *format, ...);
295
301 size_t printf(const char *format, va_list *argp);
302
307 void safePrint(unsigned char c);
308
313 void safePrint(const unsigned char *str);
314
319 void safePrint(const unsigned char *str, int32_t length);
320
325 void safePrint(char c);
326
331 void safePrint(const char *str);
332
337 void safePrint(const char *str, int32_t length);
338
341 void printBits(unsigned char value);
342
345 void printBits(uint16_t value);
346
349 void printBits(uint32_t value);
350
353 void printBits(uint64_t value);
354
357 void printBits(char value);
358
361 void printBits(int16_t value);
362
365 void printBits(int32_t value);
366
369 void printBits(int64_t value);
370
373 void printBits(unsigned char *bits, uint64_t size);
374
379 ssize_t read(uint16_t *buffer);
380
385 ssize_t read(uint32_t *buffer);
386
391 ssize_t read(uint64_t *buffer);
392
396 ssize_t read(int16_t *buffer);
397
401 ssize_t read(int32_t *buffer);
402
406 ssize_t read(int64_t *buffer);
407
412 ssize_t read(float *buffer);
413
418 ssize_t read(double *buffer);
419
424 ssize_t read(unsigned char *buffer);
425
429 ssize_t read(char *buffer);
430
434 ssize_t read(bool *buffer);
435
439 ssize_t read(unsigned char *buffer, size_t size);
440
444 ssize_t read(char *buffer, size_t size);
445
449 ssize_t read(void *buf, size_t size);
450
459 ssize_t read(char **buffer, const char *terminator);
460
472 ssize_t read(char **buffer,
473 const char *terminator, size_t maxbytes);
474
480 ssize_t read(uint16_t *buffer, int32_t sec, int32_t usec);
481
487 ssize_t read(uint32_t *buffer, int32_t sec, int32_t usec);
488
494 ssize_t read(uint64_t *buffer, int32_t sec, int32_t usec);
495
501 ssize_t read(int16_t *buffer, int32_t sec, int32_t usec);
502
508 ssize_t read(int32_t *buffer, int32_t sec, int32_t usec);
509
515 ssize_t read(int64_t *buffer, int32_t sec, int32_t usec);
516
522 ssize_t read(float *buffer, int32_t sec, int32_t usec);
523
529 ssize_t read(double *buffer, int32_t sec, int32_t usec);
530
536 ssize_t read(unsigned char *buffer, int32_t sec, int32_t usec);
537
543 ssize_t read(char *buffer, int32_t sec, int32_t usec);
544
550 ssize_t read(bool *buffer, int32_t sec, int32_t usec);
551
557 ssize_t read(unsigned char *buffer, size_t size,
558 int32_t sec, int32_t usec);
559
565 ssize_t read(char *buffer, size_t size,
566 int32_t sec, int32_t usec);
567
573 ssize_t read(void *buf, size_t size,
574 int32_t sec, int32_t usec);
575
585 ssize_t read(char **buffer, const char *terminator,
586 int32_t sec, int32_t usec);
587
600 ssize_t read(char **buffer,
601 const char *terminator, size_t maxbytes,
602 int32_t sec, int32_t usec);
603
619 ssize_t read(char **buffer,
620 const char *terminator, size_t maxbytes,
621 char escapechar, int32_t sec, int32_t usec);
622
623
643 int32_t waitForNonBlockingRead(int32_t sec, int32_t usec)
644 const;
645
666 int32_t waitForNonBlockingWrite(int32_t sec, int32_t usec)
667 const;
668
669
674 void retryInterruptedReads();
675
681 void dontRetryInterruptedReads();
682
685 bool getRetryInterruptedReads() const;
686
691 void retryInterruptedWrites();
692
698 void dontRetryInterruptedWrites();
699
702 bool getRetryInterruptedWrites() const;
703
709 void retryInterruptedWaits();
710
716 void dontRetryInterruptedWaits();
717
720 bool getRetryInterruptedWaits() const;
721
727 void retryInterruptedFcntl();
728
734 void dontRetryInterruptedFcntl();
735
738 bool getRetryInterruptedFcntl() const;
739
745 void retryInterruptedIoctl();
746
752 void dontRetryInterruptedIoctl();
753
756 bool getRetryInterruptedIoctl() const;
757
758
769 void allowShortReads();
770
776 void dontAllowShortReads();
777
789 void allowShortWrites();
790
796 void dontAllowShortWrites();
797
798
802 virtual bool passFileDescriptor(int32_t fd);
803
807 virtual bool receiveFileDescriptor(int32_t *fd);
808
809
813 virtual bool passSocket(int32_t sock);
814
818 virtual bool receiveSocket(int32_t *sock);
819
820
824 void translateByteOrder();
825
829 void dontTranslateByteOrder();
830
833 virtual int32_t fCntl(int32_t command, long arg) const;
834
837 virtual int32_t ioCtl(int32_t command, void *arg) const;
838
847 bool useNaglesAlgorithm();
848
853 bool dontUseNaglesAlgorithm();
854
859 bool setTcpWriteBufferSize(int32_t size);
860
865 bool getTcpWriteBufferSize(int32_t *size);
866
871 bool setTcpReadBufferSize(int32_t size);
872
877 bool getTcpReadBufferSize(int32_t *size);
878
882 bool disableIPv4();
883
888 bool enableIPv4();
889
894 const char *getType() const;
895
902 char *getPeerAddress() const;
903
904
926 bool setWriteBufferSize(ssize_t size) const;
927
954 bool flushWriteBuffer(int32_t sec, int32_t usec) const;
955
956
976 bool setReadBufferSize(ssize_t size) const;
977
983 bool closeOnExec();
984
991 bool dontCloseOnExec();
992
999 bool getCloseOnExec();
1000
1003 static uint16_t hostToNet(uint16_t value);
1004
1007 static uint32_t hostToNet(uint32_t value);
1008
1011 static uint64_t hostToNet(uint64_t value);
1012
1015 static uint16_t netToHost(uint16_t value);
1016
1019 static uint32_t netToHost(uint32_t value);
1020
1023 static uint64_t netToHost(uint64_t value);
1024
1025 #include <rudiments/private/filedescriptor.h>
1026 };
1027
1028 #endif
character
Definition: character.h:11
listener
Definition: listener.h:16
filedescriptor
Definition: filedescriptor.h:14
securitycontext
Definition: security.h:16