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);
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);};
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, 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);
Common C++ generic string class.
SOCKET getSocket(void)
Fetch out the socket.
SOCKET getSocket(void)
Fetch out the socket.
Network addresses and sockets related classes.
bool isPendingConnection(timeout_t timeout=ucommon::Timer::inf)
Used to wait for pending connection requests.
ssize_t peek(void *buf, size_t len)
Examine contents of next waiting packet.
TCP sockets are used for stream based connected sessions between two sockets.
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.
size_t getBufferSize(void) const
Return the size of the current stream buffering used.
The TCP session is used to primarily to represent a client connection that can be managed on a sepera...
The network name and address objects are all derived from a common IPV4Address base class...
unsigned long timeout_t
Typedef for millisecond timer values.
IPV4Host getLocal(tpport_t *port=((void *) 0)) const
Used to get local bound address.
This object is used to hold the actual and valid internet address of a specific host machine that wil...
TCPV6 sockets are used for stream based connected sessions between two ipv6 sockets.
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.
int getSegmentSize(void)
Get the buffer size for servers.
bool isPendingConnection(timeout_t timeout=ucommon::Timer::inf)
Used to wait for pending connection requests.
TCP streams are used to represent TCP client connections to a server by TCP protocol servers for acce...
This object is used to hold the actual and valid internet address of a specific host machine that wil...
IPV4Host getRequest(tpport_t *port=((void *) 0)) const
Return address and port of next connection request.