44 #ifndef COMMONCPP_TCP_H_
45 #define COMMONCPP_TCP_H_
49 #ifndef COMMONCPP_CONFIG_H_
50 #include <commoncpp/config.h>
53 #ifndef COMMONCPP_STRING_H_
57 #ifndef COMMONCPP_ADDRESS_H_
61 #ifndef COMMONCPP_SOCKET_H_
95 void setSegmentSize(
unsigned mss);
109 virtual bool onAccept(
const IPV4Host &ia, tpport_t port);
147 TCPSocket(
const char *name,
unsigned backlog = 5,
unsigned mss = 536);
158 {
return Socket::getIPV4Sender(port);}
169 {
return Socket::getIPV4Local(port);}
177 {
return Socket::isPending(Socket::pendingInput, timeout);}
214 void setSegmentSize(
unsigned mss);
228 virtual bool onAccept(
const IPV6Host &ia, tpport_t port);
236 inline int getSegmentSize(
void)
251 TCPV6Socket(
const IPV6Address &bind, tpport_t port,
unsigned backlog = 5,
unsigned mss = 536);
263 TCPV6Socket(
const char *name,
unsigned backlog = 5,
unsigned mss = 536);
274 {
return Socket::getIPV6Sender(port);}
285 {
return Socket::getIPV6Local(port);}
293 {
return Socket::isPending(Socket::pendingInput, timeout);}
315 class __EXPORT
TCPStream :
protected std::streambuf,
public Socket,
public std::iostream
320 void segmentBuffering(
unsigned mss);
340 TCPStream(Family family = IPV4,
bool throwflag =
true, timeout_t to = 0);
345 void disconnect(
void);
350 int getSegmentSize(
void);
359 void allocate(
size_t size);
365 void endStream(
void);
392 int overflow(
int ch);
402 void connect(
const IPV4Host &host, tpport_t port,
unsigned mss = 536);
404 void connect(
const IPV6Host &host, tpport_t port,
unsigned mss = 536);
414 void connect(
const char *name,
unsigned mss = 536);
424 {
return ((std::iostream *)
this);}
461 TCPStream(
const IPV4Host &host, tpport_t port,
unsigned mss = 536,
bool throwflag =
true, timeout_t timeout = 0);
463 TCPStream(
const IPV6Host &host, tpport_t port,
unsigned mss = 536,
bool throwflag =
true, timeout_t timeout = 0);
475 TCPStream(
const char *name, Family family = IPV4,
unsigned mss = 536,
bool throwflag =
false, timeout_t timer = 0);
506 size_t printf(
const char *format, ...);
515 bool isPending(Pending pend, timeout_t timeout = TIMEOUT_INF);
524 inline ssize_t
peek(
void *buf,
size_t len)
525 {return ::recv(so, (
char *)buf, (socksize_t)len, MSG_PEEK);}
563 int waitConnection(timeout_t timeout = TIMEOUT_INF);
585 tpport_t port,
size_t size = 536,
int pri = 0,
size_t stack = 0);
588 tpport_t port,
size_t size = 536,
int pri = 0,
size_t stack = 0);
int getSegmentSize(void)
Get the buffer size for servers.
IPV6Host getRequest(tpport_t *port=((void *) 0)) const
Return address and port of next connection request.
std::iostream * tcp(void)
Used in derived classes to refer to the current object via it's iostream.
size_t getBufferSize(void) const
Return the size of the current stream buffering used.
void setTimeout(timeout_t timer)
Set the I/O operation timeout for socket I/O operations.
IPV6Host getLocal(tpport_t *port=((void *) 0)) const
Used to get local bound address.
SOCKET getSocket(void)
Fetch out the socket.
SOCKET getSocket(void)
Fetch out the socket.
IPV4Host getRequest(tpport_t *port=((void *) 0)) const
Return address and port of next connection request.
The TCP session is used to primarily to represent a client connection that can be managed on a sepera...
TCPV6 sockets are used for stream based connected sessions between two ipv6 sockets.
Network addresses and sockets related classes.
bool isPendingConnection(timeout_t timeout=ucommon::Timer::inf)
Used to wait for pending connection requests.
IPV4Host getLocal(tpport_t *port=((void *) 0)) const
Used to get local bound address.
The network name and address objects are all derived from a common IPV4Address base class...
Common C++ generic string class.
ssize_t peek(void *buf, size_t len)
Examine contents of next waiting packet.
This object is used to hold the actual and valid internet address of a specific host machine that wil...
TCP streams are used to represent TCP client connections to a server by TCP protocol servers for acce...
bool isPendingConnection(timeout_t timeout=ucommon::Timer::inf)
Used to wait for pending connection requests.
TCP sockets are used for stream based connected sessions between two sockets.
This object is used to hold the actual and valid internet address of a specific host machine that wil...