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);
151 TCPSocket(
const char *name,
unsigned backlog = 5,
unsigned mss = 536);
162 return Socket::getIPV4Sender(port);
174 return Socket::getIPV4Local(port);
183 return Socket::isPending(Socket::pendingInput, timeout);
221 void setSegmentSize(
unsigned mss);
246 inline int getSegmentSize(
void) {
262 TCPV6Socket(
const IPV6Address &bind, tpport_t port,
unsigned backlog = 5,
unsigned mss = 536);
274 TCPV6Socket(
const char *name,
unsigned backlog = 5,
unsigned mss = 536);
285 return Socket::getIPV6Sender(port);
297 return Socket::getIPV6Local(port);
306 return Socket::isPending(Socket::pendingInput, timeout);
329 class __EXPORT
TCPStream :
protected std::streambuf,
public Socket,
public std::iostream
334 void segmentBuffering(
unsigned mss);
354 TCPStream(Family family = IPV4,
bool throwflag =
true, timeout_t to = 0);
359 void disconnect(
void);
364 int getSegmentSize(
void);
373 void allocate(
size_t size);
379 void endStream(
void);
387 int underflow() __OVERRIDE;
397 int uflow() __OVERRIDE;
406 int overflow(
int ch) __OVERRIDE;
428 void connect(
const char *name,
unsigned mss = 536);
437 std::iostream *
tcp(
void) {
438 return ((std::iostream *)
this);
490 TCPStream(
const char *name, Family family = IPV4,
unsigned mss = 536,
bool throwflag =
false, timeout_t timer = 0);
522 size_t printf(
const char *format, ...);
531 bool isPending(Pending pend, timeout_t timeout = TIMEOUT_INF) __OVERRIDE;
540 inline ssize_t
peek(
void *buf,
size_t len) {
541 return ::recv(so, (
char *)buf, (socksize_t)len, MSG_PEEK);
582 int waitConnection(timeout_t timeout = TIMEOUT_INF);
590 void initial(
void) __OVERRIDE;
604 tpport_t port,
size_t size = 536,
int pri = 0,
size_t stack = 0);
607 tpport_t port,
size_t size = 536,
int pri = 0,
size_t stack = 0);
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...
TCPV6 sockets are used for stream based connected sessions between two ipv6 sockets.
int getSegmentSize(void) const
Get the buffer size for servers.
IPV4Host getLocal(tpport_t *port=NULL) 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.
void setTimeout(timeout_t timer)
Set the I/O operation timeout for socket I/O operations.
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.
ssize_t peek(void *buf, size_t len)
Examine contents of next waiting packet.
in_port_t tpport_t
Transport Protocol Ports.
IPV6Host getRequest(tpport_t *port=NULL) const
Return address and port of next connection request.
IPV6Host getLocal(tpport_t *port=NULL) const
Used to get local bound address.
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.
The TCP session is used to primarily to represent a client connection that can be managed on a sepera...
TCP sockets are used for stream based connected sessions between two sockets.
SOCKET getSocket(void) const
Fetch out the socket.
IPV4Host getRequest(tpport_t *port=NULL) const
Return address and port of next connection request.
The network name and address objects are all derived from a common IPV4Address base class.