socketbase3bobcat
Base class for socket-constructing classes
Usage
#include <bobcat/socketbase>
Linking option: -lbobcat
Overview
This class is a base class for the FBB::ServerSocket and FBB::ClientSocket classes. Since it is designed as a base class, all its constructors are protected.
Namespace
FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.
Inherits from
FBB::InetAddress
Protected constructors
- o
-
SocketBase(size_t port):
This constructor creates aSocketBaseto be used withServerSocket-objects, listening on port.
- o
-
SocketBase(std::string const &host, uint16_t port):
This constructor creates aFBB::SocketBaseto be used with aClientSocket-object, connecting to hostname, at port `port’.
These constructors throw a std::exception if they could not properly complete.
The copy constructor and copy assignment operator are available. Both offer protected access rights.
Protected member
- o
-
SocketBase makeBase(int socket, sockaddr_in const &address):
This member returns aFBB::SocketBaseobject initializing its socket andFBB::InetAddressfrom the provided arguments.
Member functions
All members of FBB::InetAddress are available, as FBB::SocketBase inherits from this class.
- o
-
bool debug() const:
This accessor returnstrueif the socket’s debug (SO_DEBUG) socket option is active. It throws anFBB::Exceptionexception if the status of the debug option could not be determined;
- o
-
bool reuse() const:
This accessor returnstrueif the socket’s reuse (SO_REUSEADDR) socket option is active. It throws anFBB::Exceptionexception if the status of the reuse option could not be determined;
- o
-
void setDebug(bool trueIsOn) const:
This member may be used to modify the socket’s debug (SO_DEBUG) socket option. It throws anFBB::Exceptionexception if the socket’s debug option could not be modified;
- o
-
void setReuse(bool trueIsOn) const:
This member may be used to modify the socket’s reuse (SO_REUSEADDR) socket option. It throws anFBB::Exceptionexception if the socket’s reuse option could not be modified;
- o
-
int socket() const:
This accessor returns theFBB::SocketBase’s socket value.
Examples
The classes FBB::ClientSocket and FBB::ServerSocket were derived from SocketBase. E.g.,
#ifndef INCLUDED_BOBCAT_CLIENTSOCKET_
#define INCLUDED_BOBCAT_CLIENTSOCKET_
#include <string>
#include <bobcat/socketbase>
#include <bobcat/exception>
namespace FBB
{
class ClientSocket: public SocketBase
{
public:
// host may be address or name
ClientSocket(std::string const &host, uint16_t port);
int connect(); // returns fd (socket) to talk to the server
};
} // FBB
#endif
See the clientsocket(3bobcat) man-page for an example showing how to use FBB::ClientSocket.
Files
bobcat/socketbase - defines the class interface
Bobcat project files
- o
-
https://fbb-git.gitlab.io/bobcat/: gitlab project page;
Debian Bobcat project files:
- o
-
libbobcat6: debian package containing the shared library, changelog and copyright note;
- o
-
libbobcat-dev: debian package containing the static library, headers, manual pages, and developer info;
Bobcat
Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.
Releases
10 releases since Debian 4.0 (Etch); the text changed 9 times.