---
name: "ost_TCPV6Socket"
section: "3"
platform: "linux"
package: "libcommoncpp2-doc"
version: "1.8.1-10"
release: "Debian 11 (Bullseye)"
platforms: ["linux"]
url: "https://new.carta.tech/ost_TCPV6Socket"
---

# ost\_TCPV6Socket(3)

TCPV6 sockets are used for stream based connected sessions between two ipv6 sockets.

## NAME

ost::TCPV6Socket - TCPV6 sockets are used for stream based connected sessions between two ipv6 sockets.

## SYNOPSIS

`#include <socket.h>`

Inherits **ost::Socket**.

### Public Member Functions

virtual bool **onAccept** (const **IPV6Host** &ia, **tpport\_t** port)\
 A method to call in a derived **TCPSocket** class that is acting as a server when a connection request is being accepted.  **SOCKET** **getSocket** (void)\
 Fetch out the socket.  int **getSegmentSize** (void)\
 **TCPV6Socket** (const **IPV6Address** &bind, **tpport\_t** port, unsigned backlog=5, unsigned mss=536)\
 A TCP 'server' is created as a TCP socket that is bound to a hardware address and port number on the local machine and that has a backlog queue to listen for remote connection requests.  **TCPV6Socket** (const char \*name, unsigned backlog=5, unsigned mss=536)\
 Create a TCP server for a named host interface and service port.  **IPV6Host** **getRequest** (**tpport\_t** \*port=NULL) const\
 Return address and port of next connection request.  void **reject** (void)\
 Used to reject the next incoming connection request.  **IPV6Host** **getLocal** (**tpport\_t** \*port=NULL) const\
 Used to get local bound address.  bool **isPendingConnection** (**timeout\_t** timeout=**TIMEOUT\_INF**)\
 Used to wait for pending connection requests.  virtual **~TCPV6Socket** ()\
 Use base socket handler for ending this socket.

### Additional Inherited Members

## Detailed Description

TCPV6 sockets are used for stream based connected sessions between two ipv6 sockets.

Both error recovery and flow control operate transparently for a TCP socket connection. The TCP socket base class is primary used to bind a TCP 'server' for accepting TCP streams.

An implicit and unique **TCPV6Socket** object exists in Common C++ to represent a bound ipv6 TCP socket acting as a 'server' for receiving connection requests. This class is not part of **TCPStream** because such objects normally perform no physical I/O (read or write operations) other than to specify a listen backlog queue and perform 'accept' operations for pending connections. The Common C++ **TCPV6Socket** offers a Peek method to examine where the next pending connection is coming from, and a Reject method to flush the next request from the queue without having to create a session.

The **TCPV6Socket** also supports a 'OnAccept' method which can be called when a **TCPStream** related object is created from a **TCPSocket**. By creating a **TCPStream** from a **TCPV6Socket**, an accept operation automatically occurs, and the **TCPV6Socket** can then still reject the client connection through the return status of it's OnAccept method.

**Author**

David Sugar dyfet@tycho.com

bound server for TCP streams and sessions.

## Constructor & Destructor Documentation

### ost::TCPV6Socket::TCPV6Socket (const IPV6Address & bind, tpport\_t port, unsigned backlog = `5`, unsigned mss = `536`)

A TCP 'server' is created as a TCP socket that is bound to a hardware address and port number on the local machine and that has a backlog queue to listen for remote connection requests. If the server cannot be created, an exception is thrown.

**Parameters**

*bind* local ip address or interface to use. \
 *port* number to bind socket under. \
 *backlog* size of connection request queue. \
 *mss* maximum segment size of streaming buffer.

### ost::TCPV6Socket::TCPV6Socket (const char \* name, unsigned backlog = `5`, unsigned mss = `536`)

Create a TCP server for a named host interface and service port. We use \[host/\]port for specifying the optional host name and service port since ':' is a valid char for ipv6 addresses.

**Parameters**

*name* of host interface and service to use. \
 *backlog* size of connection request queue. \
 *mss* maximum segment size of streaming buffers.

### virtual ost::TCPV6Socket::~TCPV6Socket ()` [virtual]`

Use base socket handler for ending this socket.

## Member Function Documentation

### IPV6Host ost::TCPV6Socket::getLocal (tpport\_t \* port = `NULL`) const` [inline]`

Used to get local bound address.

References ost::Socket::getIPV6Local().

### IPV6Host ost::TCPV6Socket::getRequest (tpport\_t \* port = `NULL`) const` [inline]`

Return address and port of next connection request. This can be used instead of OnAccept() to pre-evaluate connection requests.

**Returns**

host requesting a connection.

**Parameters**

*port* number of requestor.

References ost::Socket::getIPV6Sender().

### int ost::TCPV6Socket::getSegmentSize (void)` [inline]`

### SOCKET ost::TCPV6Socket::getSocket (void)` [inline]`

Fetch out the socket.

### bool ost::TCPV6Socket::isPendingConnection (timeout\_t timeout = TIMEOUT\_INF)` [inline]`

Used to wait for pending connection requests.

**Returns**

true if data packets available.

**Parameters**

*timeout* in milliseconds. TIMEOUT\_INF if not specified.

References ost::Socket::isPending(), and ost::Socket::pendingInput.

### virtual bool ost::TCPV6Socket::onAccept (const IPV6Host & ia, tpport\_t port)` [virtual]`

A method to call in a derived **TCPSocket** class that is acting as a server when a connection request is being accepted. The server can implement protocol specific rules to exclude the remote socket from being accepted by returning false. The Peek method can also be used for this purpose.

**Returns**

true if client should be accepted.

**Parameters**

*ia* internet host address of the client. \
 *port* number of the client.

### void ost::TCPV6Socket::reject (void)

Used to reject the next incoming connection request.

## Author

Generated automatically by Doxygen for GNU CommonC++ from the source code.
