1 #ifndef __JNET__JSOCKET__ 
    2 #define __JNET__JSOCKET__ 
    4 #include <sys/socket.h> 
    6 #include <netinet/tcp.h> 
    7 #include <netinet/in.h> 
   25 namespace JPP { 
using namespace JNET; }
 
   58             const int protocol = 0) :
 
   59       JFile(socket(domain, type, protocol))
 
   91       setOption(SOL_SOCKET, SO_KEEPALIVE, 
int(on ? 1 : 0));
 
  102       return (getOption<int>(SOL_SOCKET, SO_KEEPALIVE) == 1);
 
  113       setOption(SOL_SOCKET, SO_REUSEADDR, 
int(on ? 1 : 0));
 
  124       return (getOption<int>(SOL_SOCKET, SO_REUSEADDR) == 1);
 
  135       setOption(SOL_SOCKET, SO_RCVBUF, 
int(size));
 
  146       return getOption<int>(SOL_SOCKET, SO_RCVBUF);
 
  157       setOption(SOL_SOCKET, SO_SNDBUF, 
int(size));
 
  168       return getOption<int>(SOL_SOCKET, SO_SNDBUF);
 
  183     virtual int read(
char* buffer, 
const int length)
 override  
  191       } 
else if (pos <  0) {
 
  222     virtual int write(
const char* buffer, 
const int length)
 override  
  230       } 
else if (pos <  0) {
 
  259     void setOption(
const int level, 
const int option, 
const T value)
 
  261       socklen_t size = 
sizeof(
T);
 
  280       socklen_t size  = 
sizeof(
T);
 
void setReuseAddress(const bool on)
Set reuse address. 
 
int getSendBufferSize() const 
Get send buffer size. 
 
bool getReuseAddress() const 
Get reuse address. 
 
void setSendBufferSize(const int size)
Set send buffer size. 
 
int getReceiveBufferSize() const 
Set receive buffer size. 
 
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message. 
 
virtual int read(char *buffer, const int length)
Read data from file. 
 
virtual int read(char *buffer, const int length) override
Read data from socket. 
 
bool getKeepAlive() const 
Get keep alive of socket. 
 
The JFile class extends the JAbstractFile class. 
 
int getFileDescriptor() const 
Get file descriptor. 
 
int shutdown()
Shut down socket. 
 
The JSocketAddress class encapsulates the sockaddr_in data structure. 
 
do set_variable OUTPUT_DIRECTORY $WORKDIR T
 
JSocket(const int domain, const int type, const int protocol=0)
Constructor. 
 
void setReceiveBufferSize(const int size)
Set receive buffer size. 
 
T getOption(const int level, const int option) const 
Get socket option. 
 
void setKeepAlive(const bool on)
Set keep alive of socket. 
 
JSocket()
Default constructor. 
 
void setFamily(const int family)
Set family. 
 
virtual int write(const char *buffer, const int length) override
Write data to socket. 
 
void setOption(const int level, const int option, const T value)
Set socket option. 
 
virtual int write(const char *buffer, const int length)
Write data to file.