ost::TCPSocket(3)
π ost::TCPSocket(3) π β Library Functions Manual, section 3
okay bestie, sit down, grab a strawberry π, because we're talking about ost::TCPSocket β the class that makes TCP sockets do their stream-based connected-session thing between two sockets. this is the manual page, and yes, it's gonna be a whole vibe. let's go β¨
πΈ NAME πΈ
ost::TCPSocket β TCP sockets are used for stream based connected sessions between two sockets.
like. that's it. that's the whole thing. two sockets, connected, streaming. iconic behavior honestly π
π¦ SYNOPSIS π¦
#include <socket.h>
Inherits ost::Socket. yep, it's giving legacy. it's giving inheritance. we love a base class moment π
β¨ Public Member Functions β¨
virtual bool onAccept (const IPV4Host &ia, tpport_t port)β a method to call in a derivedTCPSocketclass that is acting as a server when a connection request is being accepted.SOCKET getSocket (void)β fetch out the socket. just. hand it over. give me the socket bestie πint getSegmentSize (void)β get the buffer size for servers.TCPSocket (const IPV4Address &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.TCPSocket (const char *name, unsigned backlog=5, unsigned mss=536)β create a named tcp socket by service and/or interface id.IPV4Host 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. not me being the bouncer at the club πIPV4Host 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 ~TCPSocket ()β use base socket handler for ending this socket.
π Protected Member Functions π
void setSegmentSize (unsigned mss)β that's the whole line. no description. mysterious. we respect the privacy π
π Protected Attributes π
int segsize
π Additional Inherited Members π
(that's literally all it says. inherited members, unspecified. she's withholding information and honestly? valid.)
π Detailed Description π
TCP sockets are used for stream based connected sessions between two 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 TCPSocket object exists in Common C++ to represent a bound 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++ TCPSocket 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 TCPSocket 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 TCPSocket, an accept operation automatically occurs, and the TCPSocket 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.
Examples tcp.cpp, tcpservice.cpp, tcpstr1.cpp, and tcpthread.cpp.
literally go read those example files. they're the blueprint. iykyk β¨
π₯ Constructor & Destructor Documentation π₯
π ost::TCPSocket::TCPSocket (const IPV4Address & 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. (no cap. it will literally throw. be ready π)
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 for accepted streams.
π ost::TCPSocket::TCPSocket (const char * name, unsigned backlog = 5, unsigned mss = 536)
Create a named tcp socket by service and/or interface id. For IPV4 we use [host:]svc or [host/]svc for the string. If we have getaddrinfo, we use that to obtain the addr to bind for.
Parameters
nameβ of host interface and service port to bind.backlogβ size of connection request queue.mssβ maximum segment size for streaming buffers.
π virtual ost::TCPSocket::~TCPSocket () [virtual]
Use base socket handler for ending this socket. she's done, she's leaving, the base class is handling the goodbye π
β Member Function Documentation β
πΈ IPV4Host ost::TCPSocket::getLocal (tpport_t * port = NULL) const [inline]
Used to get local bound address.
References ost::Socket::getIPV4Local().
πΈ IPV4Host ost::TCPSocket::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. like checking the guest list before you open the door π
Returns host requesting a connection.
Parameters port number of requestor.
References ost::Socket::getIPV4Sender().
πΈ int ost::TCPSocket::getSegmentSize (void) [inline]
Get the buffer size for servers.
πΈ SOCKET ost::TCPSocket::getSocket (void) [inline]
Fetch out the socket.
πΈ bool ost::TCPSocket::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.
Examples tcpstr1.cpp, and tcpthread.cpp.
References ost::Socket::isPending(), and ost::Socket::pendingInput.
πΈ virtual bool ost::TCPSocket::onAccept (const IPV4Host & 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::TCPSocket::reject (void)
Used to reject the next incoming connection request. π« bestie said no thank u
πΈ void ost::TCPSocket::setSegmentSize (unsigned mss) [protected]
(that's it. that's the whole entry. protected. mysterious. main character energy π₯)
π§ Member Data Documentation π§
π int ost::TCPSocket::segsize [protected]
π Author π
Generated automatically by Doxygen for GNU CommonC++ from the source code.
and that's the whole page, bestie!! π this was ost::TCPSocket(3), from the GNU CommonC++ crew, dated Sun Dec 27 2020, sitting pretty under Library Functions Manual section 3 β go forth and bind your sockets responsibly, and remember: reject is a valid life choice πβ¨π¦
π¦ where this page comes from
- ubuntu jammy: libcommoncpp2-doc 1.8.1-10
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms