ucommon
|
TCPV6 sockets are used for stream based connected sessions between two ipv6 sockets. More...
#include <tcp.h>
Inherits ost::Socket.
Public Member Functions | |
IPV6Host | getLocal (tpport_t *port=((void *) 0)) |
Used to get local bound address. | |
IPV6Host | getRequest (tpport_t *port=((void *) 0)) |
Return address and port of next connection request. | |
int | getSegmentSize (void) |
SOCKET | getSocket (void) |
Fetch out the socket. | |
bool | isPendingConnection (timeout_t timeout=ucommon::Timer::inf) |
Used to wait for pending connection requests. | |
virtual bool | onAccept (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. | |
void | reject (void) |
Used to reject the next incoming connection request. | |
TCPV6Socket (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 (char *name, unsigned backlog=5, unsigned mss=536) | |
Create a TCP server for a named host interface and service port. | |
virtual | ~TCPV6Socket () |
Use base socket handler for ending this socket. |
Additional Inherited Members | |
![]() | |
enum | Error { errSuccess = 0, errCreateFailed, errCopyFailed, errInput, errInputInterrupt, errResourceFailure, errOutput, errOutputInterrupt, errNotConnected, errConnectRefused, errConnectRejected, errConnectTimeout, errConnectFailed, errConnectInvalid, errConnectBusy, errConnectNoRoute, errBindingFailed, errBroadcastDenied, errRoutingDenied, errKeepaliveDenied, errServiceDenied, errServiceUnavailable, errMulticastDisabled, errTimeout, errNoDelay, errExtended, errLookupFail, errSearchErr, errInvalidValue } |
typedef enum Error | Error |
enum | Family { IPV6 = 1, IPV4 = 2 } |
typedef enum Family | Family |
enum | Pending { pendingInput, pendingOutput, pendingError } |
typedef enum Pending | Pending |
enum | State { INITIAL, AVAILABLE, BOUND, CONNECTED, CONNECTING, STREAM } |
typedef enum State | State |
enum | Tos { tosLowDelay = 0, tosThroughput, tosReliability, tosMinCost, tosInvalid } |
typedef enum Tos | Tos |
![]() | |
struct in_addr | getaddress (IPV4Address &ia) |
struct in6_addr | getaddress (IPV6Address &ia) |
Error | getErrorNumber (void) |
Often used by a "catch" to fetch the last error of a thrown socket. | |
char * | getErrorString (void) |
Often used by a "catch" to fetch the user set error string of a thrown socket, but only if EXTENDED error codes are used. | |
IPV4Host | getIPV4Local (tpport_t *port=((void *) 0)) |
Get the local address and port number this socket is currently bound to. | |
IPV4Host | getIPV4Peer (tpport_t *port=((void *) 0)) |
Get the host address and port of the socket this socket is connected to. | |
virtual IPV4Host | getIPV4Sender (tpport_t *port=((void *) 0)) |
May be used to examine the origin of data waiting in the socket receive queue. | |
IPV6Host | getIPV6Local (tpport_t *port=((void *) 0)) |
IPV6Host | getIPV6Peer (tpport_t *port=((void *) 0)) |
virtual IPV6Host | getIPV6Sender (tpport_t *port=((void *) 0)) |
IPV4Host | getLocal (tpport_t *port=((void *) 0)) |
IPV4Host | getPeer (tpport_t *port=((void *) 0)) |
IPV4Host | getSender (tpport_t *port=((void *) 0)) |
long | getSystemError (void) |
char * | getSystemErrorString (void) |
bool | isActive (void) |
Test to see if the socket is at least operating or if it is mearly initialized. | |
bool | isBroadcast (void) |
Return if broadcast has been enabled for the specified socket. | |
bool | isConnected (void) |
Can test to see if this socket is "connected", and hence whether a "catch" can safely call getPeer(). | |
virtual bool | isPending (Pending pend, timeout_t timeout=ucommon::Timer::inf) |
Get the status of pending operations. | |
bool | isRouted (void) |
Return if socket routing is enabled. | |
operator bool () | |
bool | operator! () |
Operator based testing to see if a socket is currently active. | |
Socket & | operator= (Socket &from) |
Sockets may also be duplicated by the assignment operator. | |
void | setCompletion (bool immediate) |
Used to specify blocking mode for the socket. | |
Error | setKeepAlive (bool enable) |
Set the keep-alive status of this socket and if keep-alive messages will be sent. | |
Error | setLinger (bool linger) |
Enable lingering sockets on close. | |
Error | setTypeOfService (Tos service) |
Set packet scheduling on platforms which support ip quality of service conventions. | |
Error | bufferSize (unsigned size) |
Set the total protocol stack network kernel buffer size for both send and receive together. | |
Error | connectError (void) |
Used as a common handler for connection failure processing. | |
Error | drop (IPV4Multicast &ia) |
Drop membership from a multicast group. | |
Error | drop (IPV6Multicast &ia) |
void | endSocket (void) |
Used as the default destructor for ending a socket. | |
Error | error (Error error, char *err=((void *) 0), long systemError=0) |
This service is used to throw all socket errors which usually occur during the socket constructor. | |
void | error (char *err) |
This service is used to throw application defined socket errors where the application specific error code is a string. | |
Error | join (IPV4Multicast &ia) |
Join a multicast group. | |
Error | join (IPV6Multicast &ia) |
virtual ssize_t | readData (void *buf, size_t len, char separator=0, timeout_t t=0) |
Read in a block of len bytes with specific separator. | |
ssize_t | readLine (char *buf, size_t len, timeout_t timeout=0) |
Process a logical input line from a socket descriptor directly. | |
Error | receiveBuffer (unsigned size) |
Set the protocol stack network kernel receive buffer size associated with the socket. | |
Error | receiveLimit (int limit=1) |
Set thr receive limit. | |
Error | receiveTimeout (timeout_t timer) |
Receive timeout for receiving raw network data. | |
Error | sendBuffer (unsigned size) |
Set the protocol stack network kernel send buffer size associated with the socket. | |
Error | sendLimit (int limit=2048) |
Set the send limit. | |
Error | sendTimeout (timeout_t timer) |
Set the send timeout for sending raw network data. | |
Error | setBroadcast (bool enable) |
Set the subnet broadcast flag for the socket. | |
void | setError (bool enable) |
This service is used to turn the error handler on or off for "throwing" exceptions by manipulating the thrown flag. | |
Error | setLoopbackByFamily (bool enable, Family family=IPV4) |
Set the multicast loopback flag for the socket. | |
Error | setMulticastByFamily (bool enable, Family family=IPV4) |
Setting multicast binds the multicast interface used for the socket to the interface the socket itself has been implicitly bound to. | |
Error | setNoDelay (bool enable) |
Enable/disable delaying packets (Nagle algorithm) | |
Error | setRouting (bool enable) |
Set the socket routing to indicate if outgoing messages should bypass normal routing (set false). | |
Error | setTimeToLiveByFamily (unsigned char ttl, Family fam=IPV4) |
Set the multicast time to live for a multicast socket. | |
Socket (int domain, int type, int protocol=0) | |
An unconnected socket may be created directly on the local machine. | |
Socket (socket_t fd) | |
A socket object may be created from a file descriptor when that descriptor was created either through a socket() or accept() call. | |
Socket () | |
Create an inactive socket object for base constructors. | |
Socket (Socket &source) | |
A socket can also be constructed from an already existing Socket object. | |
virtual ssize_t | writeData (void *buf, size_t len, timeout_t t=0) |
Write a block of len bytes to socket. | |
![]() | |
static bool | check (Family fam) |
See if a specific protocol family is available in the current runtime environment. | |
static socket_t | dupSocket (socket_t s, Socket::State state) |
struct { | |
bool broadcast: 1 | |
bool completion: 1 | |
bool keepalive: 1 | |
bool linger: 1 | |
bool loopback: 1 | |
bool multicast: 1 | |
bool route: 1 | |
bool thrown: 1 | |
unsigned ttl: 8 | |
} | flags |
State volatile | state |
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.
ost::TCPV6Socket::TCPV6Socket | ( | 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.
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 | ( | 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.
name | of host interface and service to use. |
backlog | size of connection request queue. |
mss | maximum segment size of streaming buffers. |
|
inline |
|
inline |
|
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.
ia | internet host address of the client. |
port | number of the client. |