4 #ifndef RUDIMENTS_FILEDESCRIPTOR_H
5 #define RUDIMENTS_FILEDESCRIPTOR_H
7 #include <rudiments/private/filedescriptorincludes.h>
10 class filedescriptorprivate;
36 int32_t getFileDescriptor()
const;
40 void setFileDescriptor(int32_t filedesc);
51 int32_t duplicate()
const;
59 bool duplicate(int32_t newfd)
const;
61 #ifdef RUDIMENTS_HAS_SSL
69 void setSSLContext(
void *ctx);
77 void *getSSLContext();
103 void deInitializeSSL();
111 int32_t getSSLResult()
const;
116 virtual bool supportsBlockingNonBlockingModes();
121 virtual bool useNonBlockingMode()
const;
126 virtual bool useBlockingMode()
const;
130 virtual bool isUsingNonBlockingMode()
const;
135 ssize_t write(uint16_t number)
const;
140 ssize_t write(uint32_t number)
const;
145 ssize_t write(uint64_t number)
const;
150 ssize_t write(int16_t number)
const;
155 ssize_t write(int32_t number)
const;
160 ssize_t write(int64_t number)
const;
165 ssize_t write(
float number)
const;
170 ssize_t write(
double number)
const;
175 ssize_t write(
unsigned char character)
const;
180 ssize_t write(
char character)
const;
185 ssize_t write(
bool value)
const;
190 ssize_t write(
const unsigned char *
string)
const;
195 ssize_t write(
const char *
string)
const;
202 ssize_t write(
const unsigned char *
string,
size_t size)
const;
209 ssize_t write(
const char *
string,
size_t size)
const;
214 ssize_t write(
const void *buffer,
size_t size)
const;
221 ssize_t write(uint16_t number, int32_t sec, int32_t usec)
const;
228 ssize_t write(uint32_t number, int32_t sec, int32_t usec)
const;
235 ssize_t write(uint64_t number, int32_t sec, int32_t usec)
const;
242 ssize_t write(int16_t number, int32_t sec, int32_t usec)
const;
249 ssize_t write(int32_t number, int32_t sec, int32_t usec)
const;
256 ssize_t write(int64_t number, int32_t sec, int32_t usec)
const;
263 ssize_t write(
float number, int32_t sec, int32_t usec)
const;
270 ssize_t write(
double number, int32_t sec, int32_t usec)
const;
277 ssize_t write(
unsigned char character,
278 int32_t sec, int32_t usec)
const;
285 ssize_t write(
char character, int32_t sec, int32_t usec)
const;
292 ssize_t write(
bool value, int32_t sec, int32_t usec)
const;
299 ssize_t write(
const unsigned char *
string,
300 int32_t sec, int32_t usec)
const;
307 ssize_t write(
const char *
string,
308 int32_t sec, int32_t usec)
const;
316 ssize_t write(
const unsigned char *
string,
size_t size,
317 int32_t sec, int32_t usec)
const;
325 ssize_t write(
const char *
string,
size_t size,
326 int32_t sec, int32_t usec)
const;
333 ssize_t write(
const void *buffer,
size_t size,
334 int32_t sec, int32_t usec)
const;
338 size_t printf(
const char *format, ...);
345 size_t printf(
const char *format, va_list *argp);
351 void safePrint(
char c);
357 void safePrint(
const char *str);
363 void safePrint(
const char *str, int32_t length);
367 void printBits(
unsigned char value);
371 void printBits(uint16_t value);
375 void printBits(uint32_t value);
379 void printBits(uint64_t value);
383 void printBits(
char value);
387 void printBits(int16_t value);
391 void printBits(int32_t value);
395 void printBits(int64_t value);
399 void printBits(
unsigned char *bits, uint64_t size);
405 ssize_t read(uint16_t *buffer)
const;
411 ssize_t read(uint32_t *buffer)
const;
417 ssize_t read(uint64_t *buffer)
const;
422 ssize_t read(int16_t *buffer)
const;
427 ssize_t read(int32_t *buffer)
const;
432 ssize_t read(int64_t *buffer)
const;
438 ssize_t read(
float *buffer)
const;
444 ssize_t read(
double *buffer)
const;
450 ssize_t read(
unsigned char *buffer)
const;
455 ssize_t read(
char *buffer)
const;
460 ssize_t read(
bool *buffer)
const;
465 ssize_t read(
unsigned char *buffer,
size_t size)
const;
470 ssize_t read(
char *buffer,
size_t size)
const;
475 ssize_t read(
void *buf,
size_t size)
const;
485 ssize_t read(
char **buffer,
const char *terminator)
const;
492 ssize_t read(uint16_t *buffer, int32_t sec, int32_t usec)
const;
499 ssize_t read(uint32_t *buffer, int32_t sec, int32_t usec)
const;
506 ssize_t read(uint64_t *buffer, int32_t sec, int32_t usec)
const;
513 ssize_t read(int16_t *buffer, int32_t sec, int32_t usec)
const;
520 ssize_t read(int32_t *buffer, int32_t sec, int32_t usec)
const;
527 ssize_t read(int64_t *buffer, int32_t sec, int32_t usec)
const;
534 ssize_t read(
float *buffer, int32_t sec, int32_t usec)
const;
541 ssize_t read(
double *buffer, int32_t sec, int32_t usec)
const;
548 ssize_t read(
unsigned char *buffer,
549 int32_t sec, int32_t usec)
const;
556 ssize_t read(
char *buffer, int32_t sec, int32_t usec)
const;
563 ssize_t read(
bool *buffer, int32_t sec, int32_t usec)
const;
570 ssize_t read(
unsigned char *buffer,
size_t size,
571 int32_t sec, int32_t usec)
const;
578 ssize_t read(
char *buffer,
size_t size,
579 int32_t sec, int32_t usec)
const;
586 ssize_t read(
void *buf,
size_t size,
587 int32_t sec, int32_t usec)
const;
598 ssize_t read(
char **buffer,
const char *terminator,
599 int32_t sec, int32_t usec)
const;
625 int32_t waitForNonBlockingRead(int32_t sec, int32_t usec)
const;
651 int32_t waitForNonBlockingWrite(int32_t sec, int32_t usec)
const;
658 void retryInterruptedReads();
665 void dontRetryInterruptedReads();
669 bool getRetryInterruptedReads()
const;
675 void retryInterruptedWrites();
682 void dontRetryInterruptedWrites();
686 bool getRetryInterruptedWrites()
const;
693 void retryInterruptedWaits();
700 void dontRetryInterruptedWaits();
704 bool getRetryInterruptedWaits()
const;
711 void retryInterruptedFcntl();
718 void dontRetryInterruptedFcntl();
722 bool getRetryInterruptedFcntl()
const;
729 void retryInterruptedIoctl();
736 void dontRetryInterruptedIoctl();
740 bool getRetryInterruptedIoctl()
const;
753 void allowShortReads();
760 void dontAllowShortReads();
773 void allowShortWrites();
780 void dontAllowShortWrites();
799 void dontUseListener();
808 void useListenerInsideReads();
813 void dontUseListenerInsideReads();
818 void useListenerInsideWrites();
823 void dontUseListenerInsideWrites();
829 virtual bool passFileDescriptor(int32_t fd)
const;
834 virtual bool receiveFileDescriptor(int32_t *fd)
const;
840 virtual bool passSocket(int32_t sock)
const;
845 virtual bool receiveSocket(int32_t *sock)
const;
851 void translateByteOrder();
856 void dontTranslateByteOrder();
860 virtual int32_t fCntl(int32_t command,
long arg)
const;
864 virtual int32_t ioCtl(int32_t command,
void *arg)
const;
874 bool useNaglesAlgorithm();
880 bool dontUseNaglesAlgorithm();
886 bool setTcpWriteBufferSize(int32_t size);
892 bool getTcpWriteBufferSize(int32_t *size);
898 bool setTcpReadBufferSize(int32_t size);
904 bool getTcpReadBufferSize(int32_t *size);
921 const char *getType()
const;
929 char *getPeerAddress()
const;
953 bool setWriteBufferSize(ssize_t size)
const;
981 bool flushWriteBuffer(int32_t sec, int32_t usec)
const;
1003 bool setReadBufferSize(ssize_t size)
const;
1018 bool dontCloseOnExec();
1026 bool getCloseOnExec();
1030 static uint16_t hostToNet(uint16_t value);
1034 static uint32_t hostToNet(uint32_t value);
1038 static uint64_t hostToNet(uint64_t value);
1042 static uint16_t netToHost(uint16_t value);
1046 static uint32_t netToHost(uint32_t value);
1050 static uint64_t netToHost(uint64_t value);
1052 #include <rudiments/private/filedescriptor.h>