1 #ifndef __JNET__JTCPSOCKET__
2 #define __JNET__JTCPSOCKET__
18 namespace JPP {
using namespace JNET; }
56 const int mask = FNDELAY;
62 if (((flags & mask) != mask && on) ||
63 ((flags & mask) != 0 && !on) ) {
80 const int mask = FNDELAY;
86 return ((flags & mask) != 0);
130 setOption(IPPROTO_TCP, TCP_NODELAY,
int(on ? 1 : 0));
141 return (getOption<int>(IPPROTO_TCP, TCP_NODELAY) == 1);
152 socklen_t size =
sizeof(sockaddr_in);
198 void connect(
const int ip_number,
const int port)
int getIPnumber(const std::string &host_name)
Get IP number.
void setKeepIdle(const int t_s)
Set the TCP idle time.
bool getTcpNoDelay() const
Get TCP no-delay.
JTCPSocket(const int server)
Constructor.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
std::string getIPaddress(const int ip)
Get IP address (decimal-dot notation).
Auxiliary data structure for hostname and port number.
void setIPnumber()
Set any IP number.
void setKeepCnt(const int count)
Set the TCP idle count.
void connect(const std::string &hostname, const int port)
Connect to port on specified host.
const sockaddr * getSockaddr() const
Get sockaddr.
int getFileDescriptor() const
Get file descriptor.
void accept(const int server)
Accept connection from a server.
void connect(const int ip_number, const int port)
Connect to port on specified host.
void setPort(const int port)
Set port number.
void setTcpNoDelay(const bool on)
Set TCP no-delay.
bool getNonBlocking() const
Get non-blocking of I/O.
JTCPSocket()
Default constructor.
void connect(const int port)
Connect to port on local host.
void connect(const JHostname &hostname)
Connect to port on specified host.
void setNonBlocking(const bool on)
Set non-blocking of I/O.
Base class for interprocess communication.
void setOption(const int level, const int option, const T value)
Set socket option.
Hostname and IP address functions.
void setKeepIntvl(const int t_s)
Set the TCP interval time.