1 #ifndef __JNET__JTCPSOCKET__
2 #define __JNET__JTCPSOCKET__
13 #if !defined(TCP_KEEPIDLE) && defined(TCP_KEEPALIVE)
14 #define TCP_KEEPIDLE TCP_KEEPALIVE
21 namespace JPP {
using namespace JNET; }
59 const int mask = FNDELAY;
65 if (((flags & mask) != mask && on) ||
66 ((flags & mask) != 0 && !on) ) {
83 const int mask = FNDELAY;
89 return ((flags & mask) != 0);
133 setOption(IPPROTO_TCP, TCP_NODELAY,
int(on ? 1 : 0));
144 return (getOption<int>(IPPROTO_TCP, TCP_NODELAY) == 1);
155 socklen_t size =
sizeof(sockaddr_in);
189 void connect(
const std::string& hostname,
const int port)
201 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.
then usage $script< input file >[option] nPossible options count
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.