| libcosmos
    Linux C++ System Programming Library | 
Template for an active IPv4 and IPv6 based TCP connection. More...
#include <TCPConnection.hxx>
 Inheritance diagram for cosmos::TCPConnectionT< FAMILY >:
 Inheritance diagram for cosmos::TCPConnectionT< FAMILY >:| Public Member Functions | |
| TCPConnectionT (FileDescriptor fd, const AutoCloseFD auto_close=AutoCloseFD{true}) | |
| auto | tcpOptions () | 
| auto | tcpOptions () const | 
| void | sendMessage (SendMessageHeader &header) | 
| Socket::AddressFilledIn | receiveMessage (ReceiveMessageHeader &header) | 
| size_t | receive (void *buf, size_t length, const MessageFlags flags=MessageFlags{}) | 
| Receive data from the socket, using specific receive flags. | |
| size_t | send (const void *buf, size_t length, const MessageFlags flags=MessageFlags{}) | 
| Send the given data over the socket, using specific send flags. | |
| size_t | send (const std::string_view data, const MessageFlags flags=MessageFlags{}) | 
| Variant of send() that takes a std::string_view container instead of a raw input buffer. | |
|  Public Member Functions inherited from cosmos::IPSocketT< FAMILY > | |
| auto | ipOptions () | 
| auto | ipOptions () const | 
| void | getSockName (IPAddress &addr) | 
| Returns the current address that the socket is bound to, if any. | |
|  Public Member Functions inherited from cosmos::Socket | |
| auto | sockOptions () | 
| auto | sockOptions () const | 
| void | getSockName (SocketAddress &addr) | 
| Returns the current address that the socket is bound to, if any. | |
| void | shutdown (const Direction dir) | 
| Shutdown part or all of the connection on protocol level. | |
|  Public Member Functions inherited from cosmos::FDFile | |
| FDFile (const FileDescriptor fd, const AutoCloseFD auto_close) | |
| Wrap the given file descriptor applying the specified auto-close behaviour. | |
| FDFile (FDFile &&other) noexcept | |
| FDFile & | operator= (FDFile &&other) noexcept | 
| void | open (const FileDescriptor fd, const AutoCloseFD auto_close) | 
| Takes the already open file descriptor fd and operates on it. | |
| void | close () override | 
| Close the current file object. | |
|  Public Member Functions inherited from cosmos::FileBase | |
| FileBase (const FileBase &)=delete | |
| FileBase & | operator= (const FileBase &)=delete | 
| bool | isOpen () const | 
| Returns whether currently a FileDescriptor is opened. | |
| FileDescriptor | fd () const | 
| Allows access to the underlying fd with const semantics. | |
| void | truncate (const off_t length) | 
|  Public Member Functions inherited from cosmos::StreamIO | |
| StreamIO (FileDescriptor &fd) | |
| StreamIO (const StreamIO &)=delete | |
| StreamIO & | operator= (const StreamIO &)=delete | 
| StreamIO & | operator= (StreamIO &&) noexcept | 
| size_t | read (void *buf, size_t length) | 
| Read up to lengthbytes from the file intobuf. | |
| size_t | write (const void *buf, size_t length) | 
| Write up to lengthbytes frombufinto the underlying file. | |
| size_t | write (const std::string_view data) | 
| string_view wrapper around write(const void*, size_t). | |
| void | readAll (void *buf, size_t length) | 
| Read all lengthbytes from the underlying file. | |
| void | readAll (std::string &s, size_t length) | 
| Like readAll(void*, size_t) using an STL string. | |
| void | writeAll (const void *buf, size_t length) | 
| Write all lengthbytes into the underlying file. | |
| void | writeAll (const std::string_view data) | 
| string_view wrapper around writeAll(const void*, size_t). | |
| bool | read (ReadIOVector &iovec) | 
| Read data from file into a vector of data regions. | |
| bool | write (WriteIOVector &iovec) | 
| Write data to file from a vector of data regions. | |
| void | readAll (ReadIOVector &iovec) | 
| Read into all data regions specified in iovec. | |
| void | writeAll (WriteIOVector &iovec) | 
| Write all data regions specified in iovec. | |
| off_t | seek (const SeekType type, off_t off) | 
| Seek to the given offset based on the given offset type. | |
| off_t | seekFromStart (off_t off) | 
| Seek to the given offset relative to the start of the file. | |
| off_t | seekFromCurrent (off_t off) | 
| Seek to the given offset relative to the current file position. | |
| off_t | seekFromEnd (off_t off) | 
| Seek to the given offset relative to the end of the file. | |
| Additional Inherited Members | |
|  Public Types inherited from cosmos::IPSocketT< FAMILY > | |
| using | IPAddress = typename FamilyTraits<FAMILY>::Address | 
|  Public Types inherited from cosmos::Socket | |
| enum class | Direction : int { READ = SHUT_RD , WRITE = SHUT_WR , READ_WRITE = SHUT_RDWR } | 
| Type used in Socket::shutdown().  More... | |
| using | AddressFilledIn = NamedBool<struct addr_filled_in_t, false> | 
| Boolean flag used in receiveFrom() to signify if a peer address could be provided. | |
|  Public Types inherited from cosmos::StreamIO | |
| enum class | SeekType : int { SET = SEEK_SET , CUR = SEEK_CUR , END = SEEK_END , DATA = SEEK_DATA , HOLE = SEEK_HOLE } | 
| Different methods for changing the file read/write position.  More... | |
|  Protected Member Functions inherited from cosmos::IPSocketT< FAMILY > | |
| IPSocketT (const SocketType type, const SocketFlags flags=SocketFlags{SocketFlag::CLOEXEC}, const SocketProtocol protocol=SocketProtocol::DEFAULT) | |
| IPSocketT (FileDescriptor fd, const AutoCloseFD auto_close) | |
|  Protected Member Functions inherited from cosmos::Socket | |
| Socket (const SocketFamily family, const SocketType type, const SocketFlags flags=SocketFlags{SocketFlag::CLOEXEC}, const SocketProtocol protocol=SocketProtocol::DEFAULT) | |
| Creates a new socket using the given properties. | |
| Socket (FileDescriptor fd, const AutoCloseFD auto_close) | |
| Creates a new socket from the given existing file descriptor. | |
| void | bind (const SocketAddress &addr) | 
| Bind the socket to the given local address. | |
| void | connect (const SocketAddress &addr) | 
| Establish a new connection using the given destination address. | |
| void | listen (const size_t backlog) | 
| Enter into a passive listen state, allowing new connections. | |
| FileDescriptor | accept (SocketAddress *addr) | 
| Accept a new connection on the socket. | |
| size_t | send (const void *buf, size_t length, const MessageFlags flags=MessageFlags{}) | 
| Send the given data over the socket, using specific send flags. | |
| size_t | send (const std::string_view data, const MessageFlags flags=MessageFlags{}) | 
| Variant of send() that takes a std::string_view container instead of a raw input buffer. | |
| size_t | sendTo (const void *buf, size_t length, const SocketAddress &addr, const MessageFlags flags=MessageFlags{}) | 
| Send a packet to a specific destination address. | |
| size_t | sendTo (const std::string_view data, const SocketAddress &addr, const MessageFlags flags=MessageFlags{}) | 
| Variant of sendTo() that takes a std::string_view container instead of a raw input buffer. | |
| void | sendMessage (SendMessageHeader &header, const SocketAddress *addr=nullptr) | 
| Sends a message over the socket using extended SendMessageHeader data. | |
| size_t | receive (void *buf, size_t length, const MessageFlags flags=MessageFlags{}) | 
| Receive data from the socket, using specific receive flags. | |
| std::pair< size_t, AddressFilledIn > | receiveFrom (void *buf, size_t length, SocketAddress &addr, const MessageFlags flags=MessageFlags{}) | 
| Receive a packet, filling in the sender's address. | |
| AddressFilledIn | receiveMessage (ReceiveMessageHeader &header, SocketAddress *addr=nullptr) | 
| Receives a message from the socket using extended ReceiveMessageHeader data. | |
|  Protected Member Functions inherited from cosmos::FileBase | |
| FileBase (const FileDescriptor fd=FileDescriptor{}) | |
| FileBase (FileBase &&other) noexcept | |
| FileBase & | operator= (FileBase &&other) noexcept | 
|  Protected Attributes inherited from cosmos::FDFile | |
| AutoCloseFD | m_auto_close | 
|  Protected Attributes inherited from cosmos::FileBase | |
| FileDescriptor | m_fd | 
|  Protected Attributes inherited from cosmos::StreamIO | |
| FileDescriptor & | m_stream_fd | 
Template for an active IPv4 and IPv6 based TCP connection.
Use cosmos::TCP4Connection for the IPv4 variant and cosmos::TCP6Connection for the IPv6 variant.
Instances of this type are typically obtained from TCPClientSocket::connect() or TCPListenSocket::accept(). A connection can also be created from an existing file descriptor that has been obtained by other means.
Definition at line 21 of file TCPConnection.hxx.
| 
 | inlineexplicit | 
Definition at line 25 of file TCPConnection.hxx.
| size_t cosmos::Socket::receive | ( | void * | buf, | 
| size_t | length, | ||
| const MessageFlags | flags = MessageFlags{} ) | 
Receive data from the socket, using specific receive flags.
This is like a regular read() call but allows to specify socket specific MessageFlags to adjust various behaviour.
Definition at line 204 of file Socket.cxx.
| 
 | inline | 
Definition at line 44 of file TCPConnection.hxx.
| 
 | inline | 
Variant of send() that takes a std::string_view container instead of a raw input buffer.
Definition at line 153 of file Socket.hxx.
| size_t cosmos::Socket::send | ( | const void * | buf, | 
| size_t | length, | ||
| const MessageFlags | flags = MessageFlags{} ) | 
Send the given data over the socket, using specific send flags.
This is like a regular write() call but allows to specify socket specific MessageFlags to adjust various behaviour.
Definition at line 150 of file Socket.cxx.
| 
 | inline | 
Definition at line 40 of file TCPConnection.hxx.
| 
 | inline | 
Definition at line 29 of file TCPConnection.hxx.
| 
 | inline | 
Definition at line 33 of file TCPConnection.hxx.