Loading...
Searching...
No Matches
Socket.cpp File Reference
`#include <sstream>`
`#include "assa/Socket.h"`
`#include "assa/XDRHack.h"`

Go to the source code of this file.

## Macros

#define | LONGEST long
#define | READ_INT(TYPE)
#define | WRITE_INT(TYPE)

## Macro Definition Documentation

## LONGEST

#define LONGEST long

Definition at line 428 of file Socket.cpp.

## READ_INT

#define READ_INT | ( |  | TYPE | ) |

Value:
Socket& Socket::operator>>(TYPE& n_) \
{\
LONGEST val;\
int typesz = sizeof(TYPE);\
if (read ( (char* ) &val, typesz) == typesz) {\
if (sizeof(int32_t) <= typesz) {\
n_ = (TYPE) ntohl (val); \
}\
else {\
if (Socket::is_little_endian ()) {\
*((int32_t*)(&n_)+1) = ntohl (*((int32_t*)(&val)) );\
*((int32_t*)(&n_) ) = ntohl (*((int32_t*)(&val))+1);\
}\
else {\
*((int32_t*)(&n_) ) = ntohl (*((int32_t*)(&val)) );\
*((int32_t*)(&n_)+1) = ntohl (*((int32_t*)(&val))+1);\
}\
}\
}\
else {\
setstate (Socket::eofbit|Socket::failbit);\
}\
return *this;\
}
LONGEST
#define LONGEST
Definition Socket.cpp:428
ASSA::Socket
Definition Socket.h:71
ASSA::Socket::operator>>
Socket & operator>>(char &c)
Input of built-in char type. The value will be XDR-decoded.
Definition Socket.cpp:359
ASSA::Socket::is_little_endian
static bool is_little_endian()
Determine the endianess of the platform we are on.
Definition Socket.cpp:700
ASSA::Socket::eofbit
@ eofbit
indicates that an input operation reached the end of an input sequence
Definition Socket.h:82
ASSA::Socket::failbit
@ failbit
indicates that an input operation failed to read the expected characters, or that an output operation...
Definition Socket.h:84

Definition at line 436 of file Socket.cpp.

#define READ_INT(TYPE) \
Socket& Socket::operator>>(TYPE& n_) \
{\
LONGEST val;\
int typesz = sizeof(TYPE);\
if (read ( (char* ) &val, typesz) == typesz) {\
if (sizeof(int32_t) <= typesz) {\
n_ = (TYPE) ntohl (val); \
}\
else {\
if (Socket::is_little_endian ()) {\
*((int32_t*)(&n_)+1) = ntohl (*((int32_t*)(&val)) );\
*((int32_t*)(&n_) ) = ntohl (*((int32_t*)(&val))+1);\
}\
else {\
*((int32_t*)(&n_) ) = ntohl (*((int32_t*)(&val)) );\
*((int32_t*)(&n_)+1) = ntohl (*((int32_t*)(&val))+1);\
}\
}\
}\
else {\
setstate (Socket::eofbit|Socket::failbit);\
}\
return *this;\
}

## WRITE_INT

#define WRITE_INT | ( |  | TYPE | ) |

Value:
Socket& Socket::operator<< (TYPE n_) \
{ \
LONGEST val;\
int typesz = sizeof(TYPE);\
if (sizeof(int32_t) <= typesz) {\
val = (TYPE) ntohl (n_); \
}\
else {\
if (Socket::is_little_endian ()) {\
*((int32_t*)(&val)+1) = htonl (*((int32_t*)(&n_)) );\
*((int32_t*)(&val) ) = htonl (*((int32_t*)(&n_))+1);\
}\
else {\
*((int32_t*)(&val) ) = htonl (*((int32_t*)(&n_)) );\
*((int32_t*)(&val)+1) = htonl (*((int32_t*)(&n_))+1);\
}\
}\
if (write ((const char*) &val, typesz) != typesz) {\
setstate (Socket::eofbit|Socket::failbit);\
}\
return *this;\
}
ASSA::Socket::operator<<
Socket & operator<<(char c)
Output of built-in char type. The value will be XDR-encoded.
Definition Socket.cpp:508

Definition at line 588 of file Socket.cpp.

#define WRITE_INT(TYPE) \
Socket& Socket::operator<< (TYPE n_) \
{ \
LONGEST val;\
int typesz = sizeof(TYPE);\
if (sizeof(int32_t) <= typesz) {\
val = (TYPE) ntohl (n_); \
}\
else {\
if (Socket::is_little_endian ()) {\
*((int32_t*)(&val)+1) = htonl (*((int32_t*)(&n_)) );\
*((int32_t*)(&val) ) = htonl (*((int32_t*)(&n_))+1);\
}\
else {\
*((int32_t*)(&val) ) = htonl (*((int32_t*)(&n_)) );\
*((int32_t*)(&val)+1) = htonl (*((int32_t*)(&n_))+1);\
}\
}\
if (write ((const char*) &val, typesz) != typesz) {\
setstate (Socket::eofbit|Socket::failbit);\
}\
return *this;\
}