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 bool supportsSSL();
64
72 void setSSLContext(void *ctx);
73
80 void *getSSLContext();
81
91 bool initializeSSL();
92
100 void *getSSL() const;
101
106 void deInitializeSSL();
107
114 int32_t getSSLResult() const;
115
118 virtual bool supportsBlockingNonBlockingModes();
119
123 virtual bool useNonBlockingMode() const;
124
128 virtual bool useBlockingMode() const;
129
132 virtual bool isUsingNonBlockingMode() const;
133
137 ssize_t write(uint16_t number) const;
138
142 ssize_t write(uint32_t number) const;
143
147 ssize_t write(uint64_t number) const;
148
152 ssize_t write(int16_t number) const;
153
157 ssize_t write(int32_t number) const;
158
162 ssize_t write(int64_t number) const;
163
167 ssize_t write(float number) const;
168
172 ssize_t write(double number) const;
173
177 ssize_t write(unsigned char character) const;
178
182 ssize_t write(char character) const;
183
187 ssize_t write(bool value) const;
188
192 ssize_t write(const unsigned char *string) const;
193
197 ssize_t write(const char *string) const;
198
204 ssize_t write(const unsigned char *string, size_t size) const;
205
211 ssize_t write(const char *string, size_t size) const;
212
216 ssize_t write(const void *buffer, size_t size) const;
217
223 ssize_t write(uint16_t number, int32_t sec, int32_t usec) const;
224
230 ssize_t write(uint32_t number, int32_t sec, int32_t usec) const;
231
237 ssize_t write(uint64_t number, int32_t sec, int32_t usec) const;
238
244 ssize_t write(int16_t number, int32_t sec, int32_t usec) const;
245
251 ssize_t write(int32_t number, int32_t sec, int32_t usec) const;
252
258 ssize_t write(int64_t number, int32_t sec, int32_t usec) const;
259
265 ssize_t write(float number, int32_t sec, int32_t usec) const;
266
272 ssize_t write(double number, int32_t sec, int32_t usec) const;
273
279 ssize_t write(unsigned char character,
280 int32_t sec, int32_t usec) const;
281
287 ssize_t write(char character, int32_t sec, int32_t usec) const;
288
294 ssize_t write(bool value, int32_t sec, int32_t usec) const;
295
301 ssize_t write(const unsigned char *string,
302 int32_t sec, int32_t usec) const;
303
309 ssize_t write(const char *string,
310 int32_t sec, int32_t usec) const;
311
318 ssize_t write(const unsigned char *string, size_t size,
319 int32_t sec, int32_t usec) const;
320
327 ssize_t write(const char *string, size_t size,
328 int32_t sec, int32_t usec) const;
329
335 ssize_t write(const void *buffer, size_t size,
336 int32_t sec, int32_t usec) const;
337
340 size_t printf(const char *format, ...);
341
347 size_t printf(const char *format, va_list *argp);
348
353 void safePrint(unsigned char c);
354
359 void safePrint(const unsigned char *str);
360
365 void safePrint(const unsigned char *str, int32_t length);
366
371 void safePrint(char c);
372
377 void safePrint(const char *str);
378
383 void safePrint(const char *str, int32_t length);
384
387 void printBits(unsigned char value);
388
391 void printBits(uint16_t value);
392
395 void printBits(uint32_t value);
396
399 void printBits(uint64_t value);
400
403 void printBits(char value);
404
407 void printBits(int16_t value);
408
411 void printBits(int32_t value);
412
415 void printBits(int64_t value);
416
419 void printBits(unsigned char *bits, uint64_t size);
420
425 ssize_t read(uint16_t *buffer) const;
426
431 ssize_t read(uint32_t *buffer) const;
432
437 ssize_t read(uint64_t *buffer) const;
438
442 ssize_t read(int16_t *buffer) const;
443
447 ssize_t read(int32_t *buffer) const;
448
452 ssize_t read(int64_t *buffer) const;
453
458 ssize_t read(float *buffer) const;
459
464 ssize_t read(double *buffer) const;
465
470 ssize_t read(unsigned char *buffer) const;
471
475 ssize_t read(char *buffer) const;
476
480 ssize_t read(bool *buffer) const;
481
485 ssize_t read(unsigned char *buffer, size_t size) const;
486
490 ssize_t read(char *buffer, size_t size) const;
491
495 ssize_t read(void *buf, size_t size) const;
496
505 ssize_t read(char **buffer, const char *terminator) const;
506
512 ssize_t read(uint16_t *buffer, int32_t sec, int32_t usec) const;
513
519 ssize_t read(uint32_t *buffer, int32_t sec, int32_t usec) const;
520
526 ssize_t read(uint64_t *buffer, int32_t sec, int32_t usec) const;
527
533 ssize_t read(int16_t *buffer, int32_t sec, int32_t usec) const;
534
540 ssize_t read(int32_t *buffer, int32_t sec, int32_t usec) const;
541
547 ssize_t read(int64_t *buffer, int32_t sec, int32_t usec) const;
548
554 ssize_t read(float *buffer, int32_t sec, int32_t usec) const;
555
561 ssize_t read(double *buffer, int32_t sec, int32_t usec) const;
562
568 ssize_t read(unsigned char *buffer,
569 int32_t sec, int32_t usec) const;
570
576 ssize_t read(char *buffer, int32_t sec, int32_t usec) const;
577
583 ssize_t read(bool *buffer, int32_t sec, int32_t usec) const;
584
590 ssize_t read(unsigned char *buffer, size_t size,
591 int32_t sec, int32_t usec) const;
592
598 ssize_t read(char *buffer, size_t size,
599 int32_t sec, int32_t usec) const;
600
606 ssize_t read(void *buf, size_t size,
607 int32_t sec, int32_t usec) const;
608
618 ssize_t read(char **buffer, const char *terminator,
619 int32_t sec, int32_t usec) const;
620
621
641 int32_t waitForNonBlockingRead(int32_t sec, int32_t usec)
642 const;
643
664 int32_t waitForNonBlockingWrite(int32_t sec, int32_t usec)
665 const;
666
667
672 void retryInterruptedReads();
673
679 void dontRetryInterruptedReads();
680
683 bool getRetryInterruptedReads() const;
684
689 void retryInterruptedWrites();
690
696 void dontRetryInterruptedWrites();
697
700 bool getRetryInterruptedWrites() const;
701
707 void retryInterruptedWaits();
708
714 void dontRetryInterruptedWaits();
715
718 bool getRetryInterruptedWaits() const;
719
725 void retryInterruptedFcntl();
726
732 void dontRetryInterruptedFcntl();
733
736 bool getRetryInterruptedFcntl() const;
737
743 void retryInterruptedIoctl();
744
750 void dontRetryInterruptedIoctl();
751
754 bool getRetryInterruptedIoctl() const;
755
756
767 void allowShortReads();
768
774 void dontAllowShortReads();
775
787 void allowShortWrites();
788
794 void dontAllowShortWrites();
795
796
800 virtual bool passFileDescriptor(int32_t fd) const;
801
805 virtual bool receiveFileDescriptor(int32_t *fd) const;
806
807
811 virtual bool passSocket(int32_t sock) const;
812
816 virtual bool receiveSocket(int32_t *sock) const;
817
818
822 void translateByteOrder();
823
827 void dontTranslateByteOrder();
828
831 virtual int32_t fCntl(int32_t command, long arg) const;
832
835 virtual int32_t ioCtl(int32_t command, void *arg) const;
836
845 bool useNaglesAlgorithm();
846
851 bool dontUseNaglesAlgorithm();
852
857 bool setTcpWriteBufferSize(int32_t size);
858
863 bool getTcpWriteBufferSize(int32_t *size);
864
869 bool setTcpReadBufferSize(int32_t size);
870
875 bool getTcpReadBufferSize(int32_t *size);
876
880 bool disableIPv4();
881
886 bool enableIPv4();
887
892 const char *getType() const;
893
900 char *getPeerAddress() const;
901
902
924 bool setWriteBufferSize(ssize_t size) const;
925
952 bool flushWriteBuffer(int32_t sec, int32_t usec) const;
953
954
974 bool setReadBufferSize(ssize_t size) const;
975
981 bool closeOnExec();
982
989 bool dontCloseOnExec();
990
997 bool getCloseOnExec();
998
1001 static uint16_t hostToNet(uint16_t value);
1002
1005 static uint32_t hostToNet(uint32_t value);
1006
1009 static uint64_t hostToNet(uint64_t value);
1010
1013 static uint16_t netToHost(uint16_t value);
1014
1017 static uint32_t netToHost(uint32_t value);
1018
1021 static uint64_t netToHost(uint64_t value);
1022
1023 #include <rudiments/private/filedescriptor.h>
1024 };
1025
1026 #endif
character
Definition: character.h:11
listener
Definition: listener.h:16
filedescriptor
Definition: filedescriptor.h:14