43 #ifndef COMMONCPP_TCP_H_
44 #define COMMONCPP_TCP_H_
48 #ifndef COMMONCPP_CONFIG_H_
49 #include <commoncpp/config.h>
52 #ifndef COMMONCPP_STRING_H_
56 #ifndef COMMONCPP_ADDRESS_H_
60 #ifndef COMMONCPP_SOCKET_H_
94 void setSegmentSize(
unsigned mss);
108 virtual bool onAccept(
const IPV4Host &ia, tpport_t port);
146 TCPSocket(
const char *name,
unsigned backlog = 5,
unsigned mss = 536);
157 {
return Socket::getIPV4Sender(port);}
168 {
return Socket::getIPV4Local(port);}
176 {
return Socket::isPending(Socket::pendingInput, timeout);}
213 void setSegmentSize(
unsigned mss);
227 virtual bool onAccept(
const IPV6Host &ia, tpport_t port);
235 inline int getSegmentSize(
void)
250 TCPV6Socket(
const IPV6Address &bind, tpport_t port,
unsigned backlog = 5,
unsigned mss = 536);
262 TCPV6Socket(
const char *name,
unsigned backlog = 5,
unsigned mss = 536);
273 {
return Socket::getIPV6Sender(port);}
284 {
return Socket::getIPV6Local(port);}
292 {
return Socket::isPending(Socket::pendingInput, timeout);}
314 class __EXPORT
TCPStream :
protected std::streambuf,
public Socket,
public std::iostream
319 void segmentBuffering(
unsigned mss);
344 void disconnect(
void);
349 int getSegmentSize(
void);
358 void allocate(
size_t size);
364 void endStream(
void);
391 int overflow(
int ch);
401 void connect(
const IPV4Host &host, tpport_t port,
unsigned mss = 536);
403 void connect(
const IPV6Host &host, tpport_t port,
unsigned mss = 536);
413 void connect(
const char *name,
unsigned mss = 536);
423 {
return ((std::iostream *)
this);};
474 TCPStream(
const char *name, Family family = IPV4,
unsigned mss = 536,
bool throwflag =
false,
timeout_t timer = 0);
505 size_t printf(
const char *format, ...);
514 bool isPending(Pending pend,
timeout_t timeout = TIMEOUT_INF);
523 inline ssize_t
peek(
void *buf,
size_t len)
524 {return ::recv(so, (
char *)buf, len, MSG_PEEK);};
562 int waitConnection(
timeout_t timeout = TIMEOUT_INF);
584 tpport_t port,
size_t size = 536,
int pri = 0,
size_t stack = 0);
587 tpport_t port,
size_t size = 536,
int pri = 0,
size_t stack = 0);
IPV6Host getRequest(tpport_t *port=((void *) 0)) const
Return address and port of next connection request.
SOCKET getSocket(void)
Fetch out the socket.
size_t getBufferSize(void) const
Return the size of the current stream buffering used.
IPV4Host getRequest(tpport_t *port=((void *) 0)) const
Return address and port of next connection request.
bool isPendingConnection(timeout_t timeout=ucommon::Timer::inf)
Used to wait for pending connection requests.
TCPV6 sockets are used for stream based connected sessions between two ipv6 sockets.
std::iostream * tcp(void)
Used in derived classes to refer to the current object via it's iostream.
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...
The network name and address objects are all derived from a common IPV4Address base class...
ssize_t peek(void *buf, size_t len)
Examine contents of next waiting packet.
IPV6Host 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...
Network addresses and sockets related classes.
SOCKET getSocket(void)
Fetch out the socket.
Common C++ generic string class.
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.
IPV4Host getLocal(tpport_t *port=((void *) 0)) const
Used to get local bound address.
int getSegmentSize(void)
Get the buffer size for servers.
unsigned long timeout_t
Typedef for millisecond timer values.
The TCP session is used to primarily to represent a client connection that can be managed on a sepera...
void setTimeout(timeout_t timer)
Set the I/O operation timeout for socket I/O operations.