4 #ifndef RUDIMENTS_FILEDESCRIPTOR_H
5 #define RUDIMENTS_FILEDESCRIPTOR_H
7 #include <rudiments/private/filedescriptorincludes.h>
9 #ifdef RUDIMENTS_NAMESPACE
14 class filedescriptorprivate;
40 int32_t getFileDescriptor()
const;
44 void setFileDescriptor(int32_t filedesc);
55 int32_t duplicate()
const;
63 bool duplicate(int32_t newfd)
const;
65 #ifdef RUDIMENTS_HAS_SSL
70 void setSSLContext(SSL_CTX *ctx);
75 SSL_CTX *getSSLContext();
98 void deInitializeSSL();
106 int32_t getSSLResult()
const;
112 virtual bool useNonBlockingMode()
const;
117 virtual bool useBlockingMode()
const;
121 bool isUsingNonBlockingMode()
const;
126 ssize_t write(uint16_t number)
const;
131 ssize_t write(uint32_t number)
const;
136 ssize_t write(uint64_t number)
const;
141 ssize_t write(int16_t number)
const;
146 ssize_t write(int32_t number)
const;
151 ssize_t write(int64_t number)
const;
156 ssize_t write(
float number)
const;
161 ssize_t write(
double number)
const;
166 ssize_t write(
unsigned char character)
const;
171 ssize_t write(
char character)
const;
176 ssize_t write(
bool value)
const;
181 ssize_t write(
const unsigned char *
string)
const;
186 ssize_t write(
const char *
string)
const;
193 ssize_t write(
const unsigned char *
string,
size_t size)
const;
200 ssize_t write(
const char *
string,
size_t size)
const;
205 ssize_t write(
const void *buffer,
size_t size)
const;
212 ssize_t write(uint16_t number,
long sec,
long usec)
const;
219 ssize_t write(uint32_t number,
long sec,
long usec)
const;
226 ssize_t write(uint64_t number,
long sec,
long usec)
const;
233 ssize_t write(int16_t number,
long sec,
long usec)
const;
240 ssize_t write(int32_t number,
long sec,
long usec)
const;
247 ssize_t write(int64_t number,
long sec,
long usec)
const;
254 ssize_t write(
float number,
long sec,
long usec)
const;
261 ssize_t write(
double number,
long sec,
long usec)
const;
268 ssize_t write(
unsigned char character,
269 long sec,
long usec)
const;
276 ssize_t write(
char character,
long sec,
long usec)
const;
283 ssize_t write(
bool value,
long sec,
long usec)
const;
290 ssize_t write(
const unsigned char *
string,
291 long sec,
long usec)
const;
298 ssize_t write(
const char *
string,
299 long sec,
long usec)
const;
307 ssize_t write(
const unsigned char *
string,
size_t size,
308 long sec,
long usec)
const;
316 ssize_t write(
const char *
string,
size_t size,
317 long sec,
long usec)
const;
324 ssize_t write(
const void *buffer,
size_t size,
325 long sec,
long usec)
const;
331 ssize_t read(uint16_t *buffer)
const;
337 ssize_t read(uint32_t *buffer)
const;
343 ssize_t read(uint64_t *buffer)
const;
348 ssize_t read(int16_t *buffer)
const;
353 ssize_t read(int32_t *buffer)
const;
358 ssize_t read(int64_t *buffer)
const;
364 ssize_t read(
float *buffer)
const;
370 ssize_t read(
double *buffer)
const;
376 ssize_t read(
unsigned char *buffer)
const;
381 ssize_t read(
char *buffer)
const;
386 ssize_t read(
bool *buffer)
const;
391 ssize_t read(
unsigned char *buffer,
size_t size)
const;
396 ssize_t read(
char *buffer,
size_t size)
const;
401 ssize_t read(
void *buf,
size_t size)
const;
411 ssize_t read(
char **buffer,
const char *terminator)
const;
418 ssize_t read(uint16_t *buffer,
long sec,
long usec)
const;
425 ssize_t read(uint32_t *buffer,
long sec,
long usec)
const;
432 ssize_t read(uint64_t *buffer,
long sec,
long usec)
const;
439 ssize_t read(int16_t *buffer,
long sec,
long usec)
const;
446 ssize_t read(int32_t *buffer,
long sec,
long usec)
const;
453 ssize_t read(int64_t *buffer,
long sec,
long usec)
const;
460 ssize_t read(
float *buffer,
long sec,
long usec)
const;
467 ssize_t read(
double *buffer,
long sec,
long usec)
const;
474 ssize_t read(
unsigned char *buffer,
475 long sec,
long usec)
const;
482 ssize_t read(
char *buffer,
long sec,
long usec)
const;
489 ssize_t read(
bool *buffer,
long sec,
long usec)
const;
496 ssize_t read(
unsigned char *buffer,
size_t size,
497 long sec,
long usec)
const;
504 ssize_t read(
char *buffer,
size_t size,
505 long sec,
long usec)
const;
512 ssize_t read(
void *buf,
size_t size,
513 long sec,
long usec)
const;
524 ssize_t read(
char **buffer,
const char *terminator,
525 long sec,
long usec)
const;
551 int32_t waitForNonBlockingRead(
long sec,
long usec)
const;
577 int32_t waitForNonBlockingWrite(
long sec,
long usec)
const;
584 void retryInterruptedReads();
591 void dontRetryInterruptedReads();
597 void retryInterruptedWrites();
604 void dontRetryInterruptedWrites();
611 void retryInterruptedWaits();
618 void dontRetryInterruptedWaits();
625 void retryInterruptedFcntl();
632 void dontRetryInterruptedFcntl();
639 void retryInterruptedIoctl();
646 void dontRetryInterruptedIoctl();
659 void allowShortReads();
666 void dontAllowShortReads();
679 void allowShortWrites();
686 void dontAllowShortWrites();
705 void dontUseListener();
714 void useListenerInsideReads();
719 void dontUseListenerInsideReads();
724 void useListenerInsideWrites();
729 void dontUseListenerInsideWrites();
735 virtual bool passFileDescriptor(int32_t fd)
const;
740 virtual bool receiveFileDescriptor(int32_t *fd)
const;
745 void translateByteOrder();
750 void dontTranslateByteOrder();
754 int32_t fCntl(int32_t command,
long arg)
const;
758 int32_t ioCtl(int32_t command,
void *arg)
const;
768 bool useNaglesAlgorithm();
774 bool dontUseNaglesAlgorithm();
780 bool setTcpWriteBufferSize(int32_t size);
786 bool getTcpWriteBufferSize(int32_t *size);
792 bool setTcpReadBufferSize(int32_t size);
798 bool getTcpReadBufferSize(int32_t *size);
804 const char *getType()
const;
812 char *getPeerAddress()
const;
836 bool setWriteBufferSize(ssize_t size)
const;
864 bool flushWriteBuffer(
long sec,
long usec)
const;
886 bool setReadBufferSize(ssize_t size)
const;
901 bool dontCloseOnExec();
909 bool getCloseOnExec();
913 static uint16_t hostToNet(uint16_t value);
917 static uint32_t hostToNet(uint32_t value);
921 static uint64_t hostToNet(uint64_t value);
925 static uint16_t netToHost(uint16_t value);
929 static uint32_t netToHost(uint32_t value);
933 static uint64_t netToHost(uint64_t value);
935 #include <rudiments/private/filedescriptor.h>
938 #ifdef RUDIMENTS_NAMESPACE