Go to the documentation of this file.    1 #ifndef __JNET__JSOCKET__ 
    2 #define __JNET__JSOCKET__ 
    4 #include <sys/socket.h> 
    6 #include <netinet/tcp.h> 
    7 #include <netinet/in.h> 
   29 namespace JPP { 
using namespace JNET; }
 
   61       JFile(socket(PF_INET, type, 0))
 
   80             const int protocol = 0) :
 
   81       JFile(socket(domain, type, protocol))
 
  112       const int mask  = FNDELAY;
 
  118       if (((flags & mask) != mask &&  on) ||
 
  119           ((flags & mask) != 0    && !on) ) {
 
  136       const int mask  = FNDELAY;
 
  142       return ((flags & mask) != 0);
 
  153       setOption(SOL_SOCKET, SO_KEEPALIVE, 
int(on ? 1 : 0));
 
  164       return (getOption<int>(SOL_SOCKET, SO_KEEPALIVE) == 1);
 
  208       setOption(SOL_SOCKET, SO_REUSEADDR, 
int(on ? 1 : 0));
 
  219       return (getOption<int>(SOL_SOCKET, SO_REUSEADDR) == 1);
 
  230       setOption(IPPROTO_TCP, TCP_NODELAY, 
int(on ? 1 : 0));
 
  241       return (getOption<int>(IPPROTO_TCP, TCP_NODELAY) == 1);
 
  252       setOption(SOL_SOCKET, SO_RCVBUF, 
int(size));
 
  263       return getOption<int>(SOL_SOCKET, SO_RCVBUF);
 
  274       setOption(SOL_SOCKET, SO_SNDBUF, 
int(size));
 
  285       return getOption<int>(SOL_SOCKET, SO_SNDBUF);
 
  300     virtual int read(
char* buffer, 
const int length)
 
  308       } 
else if (pos <  0) {
 
  339     virtual int write(
const char* buffer, 
const int length)
 
  347       } 
else if (pos <  0) {
 
  374       socklen_t size = 
sizeof(sockaddr_in);
 
  396     void connect(
const std::string& host_name, 
const int port)
 
  408     void connect(
const int ip_number, 
const int port)
 
  428     void setOption(
const int level, 
const int option, 
const T value)
 
  430       socklen_t size = 
sizeof(T);
 
  449       socklen_t size  = 
sizeof(T);
 
 
int getFileDescriptor() const
Get file descriptor.
 
virtual int read(char *buffer, const int length)
Read data from socket.
 
JSocket()
Default constructor.
 
void setSendBufferSize(const int size)
Set send buffer size.
 
void setReuseAddress(const bool on)
Set reuse address.
 
const sockaddr * getSockaddr() const
Get sockaddr.
 
void setKeepIdle(const int t_s)
Set the TCP idle time.
 
void setKeepIntvl(const int t_s)
Set the TCP interval time.
 
Interprocess communication.
 
virtual int read(char *buffer, const int length)
Read data from file.
 
void setTcpNoDelay(const bool on)
Set TCP no-delay.
 
int shutdown()
Shut down socket.
 
void setReceiveBufferSize(const int size)
Set receive buffer size.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
bool getTcpNoDelay() const
Get TCP no-delay.
 
void connect(const std::string &host_name, const int port)
Connect to port on specified host.
 
void setKeepCnt(const int count)
Set the TCP idle count.
 
JSocket(const int type)
Constructor.
 
void connect(const int ip_number, const int port)
Connect to port on specified host.
 
void accept(const int server)
Accept connection from a server.
 
virtual int write(const char *buffer, const int length)
Write data to socket.
 
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
 
The JFile class extends the JAbstractFile class.
 
void setIPnumber()
Set any IP number.
 
int getSendBufferSize() const
Get send buffer size.
 
void setFamily(const int family)
Set family.
 
void setKeepAlive(const bool on)
Set keep alive of socket.
 
T getOption(const int level, const int option) const
Get socket option.
 
void setOption(const int level, const int option, const T value)
Set socket option.
 
bool getReuseAddress() const
Get reuse address.
 
void connect(const int port)
Connect to port on local host.
 
std::string getHostname()
Get host name.
 
void setNonBlocking(const bool on)
Set non-blocking of I/O.
 
bool getKeepAlive() const
Get keep alive of socket.
 
JSocket(const int domain, const int type, const int protocol=0)
Constructor.
 
The JSocketAddress class encapsulates the sockaddr_in data structure.
 
void setPort(const int port)
Set port number.
 
int getIPnumber(const std::string &host_name)
Get IP number.
 
virtual int write(const char *buffer, const int length)
Write data to file.
 
bool getNonBlocking() const
Get non-blocking of I/O.
 
int getReceiveBufferSize() const
Set receive buffer size.